Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- cout << "enter symbols(words)(limit 30 symbols)" << endl;
- char userWords[31];
- cin.getline(userWords,31);
- cout << "these symbols are taking part in the test now" << endl;
- cout << userWords << endl;
- int symbolNum,symbol,word,i;
- symbolNum = 31;
- symbol = 1;
- word = 0;
- for( i=0;i<symbolNum;i++){
- if(userWords[i] = '\0'){
- symbolNum=i;
- }
- }
- // for
- for (i=0;i < symbolNum;i++){
- if(userWords[i] = '\0'){
- symbolNum=i;
- break;
- }
- }
- // for
- for( i = 0 ; i < symbolNum; i++){
- symbol = i;
- if((userWords[symbol] >= 'A' && userWords[symbol] <= 'Z') || (userWords[symbol] >= 'a' && userWords[symbol] <= 'z' || userWords[symbol] == '-')){
- if(!(userWords[symbol+1] >= 'A' && userWords[symbol+1] <= 'Z') || (userWords[symbol+1] >= 'a' && userWords[symbol+1] <= 'z' || userWords[symbol+1] == '-')){
- word++;
- }else{
- continue;
- }
- }
- // if
- cout << endl;
- cout << word << "word(s) in line" << i;
- }
- //for
- cout << word << "word(s) in line";
- cout << endl << "-------------------------------";
- }
- // int main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement