ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1567. SMS-spam

what is my problem on c++?
Posted by nick nikuradze 23 Apr 2016 18:42
This is my code!!!
#include<iostream>
#include<string>
using namespace std;
int main() {
 char s;
 int count = 0;
 while (cin >> s) {
    if ((s=='a')||
        (s=='d')||
        (s=='g')||
        (s=='j')||
        (s=='m')||
        (s=='p')||
        (s=='s')||
        (s=='v')||
        (s=='y')||
        (s=='.')||
        (s==' ')) {count+=1;}
    if ((s=='b')||
        (s=='e')||
        (s=='h')||
        (s=='k')||
        (s=='n')||
        (s=='q')||
        (s=='t')||
        (s=='w')||
        (s=='z')||
        (s==',')) {count+=2;}
    if ((s=='c')||
        (s=='f')||
        (s=='i')||
        (s=='l')||
        (s=='o')||
        (s=='r')||
        (s=='u')||
        (s=='x')||
        (s=='!')) {count+=3;}
 }
 cout << count;
system("pause");
 return 0;
}
Re: what is my problem on c++?
Posted by Horia 17 Sep 2017 01:40
Possibly this part (s==' '))
Re: what is my problem on c++?
Posted by John 11 Jan 2022 23:11
If anyone is confused about this, note that cin ignores spaces. You should read the line as a whole with getline.

string s;
getline(cin, s);