You are viewing a single comment's thread. Return to all comments →
Please help me on my program as this is not working altjough getting correct output:
#include <cstdio>
using namespace std;
int main() {
string s;
while (getline(cin, s)) {
int n=s.size(); if(s[0] == 'S' && s[2]=='M' && s[n-1]== ')'){ for(int i=4 ; i<n-2 ; i++){ if (isupper(s[i])) { cout << " " << (char)tolower(s[i]); } else { cout << s[i]; } } cout<<endl; } if(s[0]=='C' && s[2]=='V'){ for(int i=4 ; i<n ; i++){ if ((s[i]) == ' ') { cout << (char)toupper(s[i+1]); i++; } else { cout << s[i]; } } cout<<endl; } if(s[0] == 'C' && s[2]=='C' ){ cout<< (char)toupper(s[4]); for(int i=5 ; i<n ; i++){ if ((s[i]) == ' ') { cout << (char)toupper(s[i+1]); i++; } else { cout << s[i]; } } cout<<endl; } if(s[0] == 'S' && s[2]=='C' ){ cout<< (char)tolower(s[4]); for(int i=5 ; i<n ; i++){ if (isupper(s[i])) { cout << ' ' << (char)tolower(s[i]); } else { cout << s[i]; } } cout<<endl; } if(s[0] == 'C' && s[2]=='M' ){ string r; for(int i=4 ; i<n ; i++){ if ((s[i]) == ' ') { r=r+(char)toupper(s[i+1]); i++; } else { r=r+s[i]; } } r=r+"()"; cout << r <<endl; } if(s[0] == 'S' && s[2]=='V' ){ cout<< (char)tolower(s[4]); for(int i=5 ; i<n ; i++){ if (isupper(s[i])) { cout << ' ' << (char)tolower(s[i]); } else { cout << s[i]; } } cout<<endl; }
} /* Enter your code here. Read input from STDIN. Print output to STDOUT */ return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Camel Case 4
You are viewing a single comment's thread. Return to all comments →
Please help me on my program as this is not working altjough getting correct output:
include
include
include
include
using namespace std;
int main() {
while (getline(cin, s)) {
} /* Enter your code here. Read input from STDIN. Print output to STDOUT */
return 0; }