- #include<stdio.h>
- #include<string.h>
- int main()
- {
- int b[500];
- char a[500];
- int h;
- int n;
- while(gets(a))
- {
- memset(b,0,sizeof b);
- int z=0;
- n=strlen(a);
- for(int i=0;i<n;i++)
- {
- if((a[i]>='a'&&a[i]<='z')||(a[i]>='A'&&a[i]<='Z'))
- b[a[i]]++;
- }
- h = 255;
- for(int i=0;i<n;i++)
- {
- if(b[a[i]]>z&&a[i]!=' ')
- {
- z=b[a[i]];
- h=a[i];
- }
- else if(b[a[i]]==z&&a[i]!=' '&&a[i]<h)
- {
- z=b[a[i]];
- h=a[i];
- }
- }
- printf("%c %d\n",(char)h,z);
- }
- return 0;
- }
Re: 字符统计2
From Anorexic Cheetah, 3 Years ago, written in Plain Text, viewed 384 times.
This paste is a reply to 字符统计2 from 李清璇
- view diff
URL http://axuhongbo.top/paste/view/706453de
Embed
Download Paste or View Raw
— Expand Paste to full width of browser