该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include
void compare(char a[],char b[])
{
char t[1000];
memset(t,0,sizeof(t));
for(int i=0;i<1000;i++){
if(strcmp(a,b)<0){
strcpy(t,a);
strcpy(a,b);
strcpy(b,t);
return;
}
else
return;
}
return;
}
int main(){
char a[1000][55],ch;
int count[1000]={0};
int jj[1000]={0};
int n=0,m=0;
memset(a,0,sizeof(a));
while((ch=getchar())!='\n'){
if(ch==' '){
m++;
n=0;
continue;
}
a[m][n++]=ch;
}
int i=0;
for(i=0;i<=m;i++){
for(int j=0;j<=m-1;j++){
compare(a[j],a[j+1]);
}
}
int e=1;
for(i=0;i<=m;i++){
count[i]=1;
for(int j=m;j>i;j--){
if(strcmp(a[i],a[j])==0){
count[i]++;
}
}
}
for(i=0;i<=m;i++){
for(int j=m;j>i;j--){
if(strcmp(a[i],a[j])==0){
jj[e++]=j;
}
}
}
int t=m+1;
while(t>0){
t--;
while(t>0&&a[t]==0)t--;
int h=1;
while(h<=e){
while(t>0&&t==jj[h]){
t--;
h=0;
}
h++;
}
printf("%s %d\n",a[t],count[t]);
}
return 0;
}