0

it needs to make sure numbers aren't duplicate and are ordered. maybe change my cout statements to arrays?
Thanks.
This is what program is supposed to do
input
Q 1,2,3-5,6-7
output
do problem 1,2,3,4,5,6,7 of Q.

#include <iostream>
#include <cstdlib>
#include <sstream>
#include <string>
using namespace std;

int main()
{


    cout <<"enter the problemset and number""\n";
    //problems represents name and numbers
    string problems;
    char quote;
    char num;
    short number, number2;
    
    //gather name
    if(cin.peek()=='"' || cin.peek() == '\'')
    {
        cin >>quote;
        getline(cin,problems,quote);
    }
    else
    {
        while (!isdigit(cin.peek()) && !isspace(cin.peek()))
        {
         //   (char)cin.peek();
            problems += cin.get();
        }
    }


    //gather problem numbers
    //cin >> num;
    
        cin>>number;
        cout<<"very beginning\n"<<number;
        
    while(cin.peek() != '\n')
    {
        
        if(cin.peek()==',')
        {
            cin.ignore();
            cin >> ws;
            if(isdigit(cin.peek()))
            {
                cin>>number;
                cout<<"from comma\n"<<number<<"\n";
            }
        }
       
        else if(cin.peek()=='-')
        {
            cin.ignore();
            cin >> ws;
            if(isdigit(cin.peek()))
            {
                cin>>number2;
                cout<<"the value of # is\n"<<number2;
                   
                for(short a=number+1; a<=number2; a++)
                {
                    cout<<"next do #"<<a;
               
                }
            }
        }
        
    }
    
    //check for dulplicate and put in order
        
    // print them all out

    return 0;
}
2
Contributors
1
Reply
3
Views
8 Years
Discussion Span
Last Post by __avd
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.