Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- string s,s1;
- int frequency[40];
- int main()
- {
- int len,i,a;
- stringstream ss;
- while(cin>>s)
- {
- while(1)
- {
- if(s=="#")
- {
- break;
- }
- len = s.length();
- if(s[len-1]=='-')
- {
- s.erase(len-1);
- }
- else
- {
- s+=" ";
- }
- for(i=0; i<len; i++)
- {
- a = s[i];
- if(a==39)
- {
- continue;
- }
- if(s[i]=='-')
- {
- continue;
- }
- if(s[i]>='A' && s[i]<='Z')
- {
- s[i]+=32;
- }
- else if(s[i]<'a' || s[i]>'z')
- {
- s[i] = ' ';
- }
- }
- ss<<s;
- cin>>s;
- }
- while(ss>>s1)
- {
- len = s1.length();
- int len1 = len;
- for(i=0; i<len; i++)
- {
- a = s1[i];
- if(a==39)
- {
- len1--;
- }
- else if(s1[i]=='-')
- {
- len1--;
- }
- }
- frequency[len1]++;
- }
- for(i=1; i<=31; i++)
- {
- if(frequency[i]>0)
- {
- printf("%d %d\n",i,frequency[i]);
- }
- }
- puts("");
- ss.clear();
- memset(frequency,0,sizeof(frequency));
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment