?? count.txt
字號:
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
int icmp(const void *p1,const void *p2)
{
return strcmp(*(char * const *)p1,*(char * const *)p2);
}
int main()
{
char *s[100000];
int a[100000]={0};
long n,i,j,k=1,b;
while(cin>>n)
{
i=0;
while(n--)
{
s[i]=(char *)malloc(sizeof(char)*21);
cin>>s[i++];
}
qsort(s,i,sizeof(s[0]),icmp);
b=1;
for(j=0;j<i;j++)
if(j+1<i&&strcmp(s[j],s[j+1])==0)b++;
else {a[b]++;b=1;}
cout<<"Case "<<k++<<":"<<endl;
for(j=1;j<=i;j++)
{
if(a[j]!=0)
{
cout<<j<<" "<<a[j]<<endl;
a[j]=0;
}
}
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -