#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
cout <<"enter the problemset and number""\n";
//problems represents name and numbers
string problems , probtitle;
string xx;
bool x=true;
char quote;
string str1, str2;
string begin;
//gather name
if(cin.peek()=='"' || cin.peek() == '\'')
{
cin >>quote;
getline(cin,problems,quote);
}
else
{
getline(cin,problems);
}
//gather problem numbers
while(x==true)
{
if(cin.peek()=='0'||cin.peek()=='1'||cin.peek()=='2'||cin.peek()=='3'||cin.peek()=='4'||cin.peek()=='5'||cin.peek()=='6'||cin.peek()=='7'||cin.peek()=='8'||cin.peek()=='9'||cin.peek()==','||cin.peek()=='-')
{
getline(cin,problems);
}
else
{
getline(cin,xx);
if(xx.compare("\n"))
{
x=false;
}
}
}
cout<<problems;
int length=problems.find(',');
do{
if(problems.find(',') != string::npos)
{
size_t a,b;
a=problems.find(',');
b=problems.find('-');
if(problems.find('-') != string::npos&&b<a)
{
str1 = problems.substr(0,problems.find('-'));
cout<<"from do ifif1\n"<<str1;
problems=problems.erase(0,problems.find('-'));
cout<<"from erase after first erase"<<problems;
str2=problems.substr(problems.find('-')+1,problems.find(','));
cout<<"from doifif2\n"<<str2;
problems=problems.erase(0,problems.find(',')+1);
cout<<"the problems left after erase are"<<problems;
}
else
{
cout << "from do if else\n" ;
str1 = problems.substr(0,problems.find(','));
cout<<"from elseelseelseelse\n"<<str1;
problems=problems.erase(0,problems.find(',')+1);
}
}
else
{
cout <<"No Comma\n";
if(problems.find('-') != string::npos)
{
str1 = problems.substr(0,problems.find('-'));
cout<<str1;
str2=problems.substr(problems.find('-')+1);
cout<<str2;
problems=problems.erase(0,problems.find('-')+1);
}
else
{cout << "\n IF ELSE" ;
str1 = problems.substr(0,problems.find(','));
cout<<str1;
if(problems.find(',') != string::npos)
{
problems=problems.erase(0,problems.find(',')+1);
}
else{
problems="";
}
}
}
}while(problems.length()>0 );
lotrsimp12345 37 Posting Pro in Training
lotrsimp12345 37 Posting Pro in Training
lotrsimp12345 37 Posting Pro in Training
daviddoria 334 Posting Virtuoso Featured Poster
lotrsimp12345 37 Posting Pro in Training
tux4life 2,072 Postaholic
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
tux4life commented: Good point :) +9
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.