fork download
  1. //ABcDexter, puzzling.SE,q/37303/1766, 10/7/16 1211
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int i,n,t;
  6. string inp;
  7. int count[26]={0};
  8.  
  9. int main()
  10. {
  11.  
  12. //cin>>inp;
  13. char ch;
  14. int words=0,commas=0,spaces=0,periods=0;
  15.  
  16.  
  17. for(i=0; (ch=getchar()) && (ch!='\n'); i++) //for(i=0; inp[i]!='\n' ; i++)
  18. {
  19. inp+=ch;//cout<<ch;
  20. switch(ch)
  21. {
  22. case ' ' : words++,spaces++;
  23. break;
  24. case ',': commas++;
  25. break;
  26. case '.': periods++;
  27. break;
  28. default: //cout<<inp[i];
  29. if(inp[i]>='a' && inp[i]<='z') ::count[inp[i]-'a']++;
  30. else if(inp[i]>='A' && inp[i]<='Z') ::count[inp[i]-'A']++;
  31.  
  32. }//if(inp[i]=='.') break;
  33. }
  34.  
  35. cout<<"Here is the count\n";
  36. cout<<"Number of words : "<<++words<<endl; //words+1 as one more for the final word with no space at the end;
  37. for(int i=0;i<26;i++)
  38. cout<<"count of "<<char(i+65)<<" "<<::count[i]<<endl;
  39.  
  40. cout<<"Number of commas : "<<commas<<endl;
  41. cout<<"Number of spaces : "<<spaces<<endl;
  42. cout<<"Number of periods : "<<periods<<"\nsorry, don't know how to count syllables"<<endl;
  43.  
  44.  
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0s 3468KB
stdin
Give the right guess in an English sentence self answering puzzle offer that contains eighty four words, one hundred and nineteen syllables, ten As, two Bs, five Cs, seven Ds, fifty nine Es, fifteen Fs, nine Gs, fourteen Hs, twenty one Is, one J, one K, seven Ls, three Ms, forty Ns, nineteen Os, four Ps, one Q, seventeen Rs, forty Ss, thirty Ts, seven Us, eight Vs, five Ws, one X, ten Ys, three Zs, thirty commas, eighty three spaces, and one period.

stdout
Here is the count
Number of words : 84
count of A 10
count of B 2
count of C 5
count of D 7
count of E 59
count of F 15
count of G 9
count of H 14
count of I 21
count of J 1
count of K 1
count of L 7
count of M 3
count of N 40
count of O 19
count of P 4
count of Q 1
count of R 17
count of S 40
count of T 30
count of U 7
count of V 8
count of W 5
count of X 1
count of Y 10
count of Z 3
Number of commas : 30
Number of spaces : 83
Number of periods : 1
sorry, don't know how to count syllables