#include<stdio.h>//DNA序列 #include<string.h> int main() { int a,b,c,d,i,j,m,n,z[101],e,q,y; char x[101][51],y[51],temp[51]; while(scanf("%d %d",&a,&b)!=EOF)//先输入 { for(i=0;i<b;i++) scanf("%s",&x[i]);//get字符串 for(i=0;i<b;i++)//从第一条字符串开始 { z[i]=0; for(j=0;j<a;j++) { if(x[i][j]=='A')//如果当前字符串是‘A’的话,就直接加零 z[i]=z[i]+0; else { for(d=j;d<a;d++)//如果不是的话,再和它之后的字符比较 { if(x[i][j]>x[i][d])//如果比之后的字符大,就加一 z[i]=z[i]+1; } } } } //for(i=0;i<b;i++) //printf("%d ",z[i]); for(i=0;i<b;i++) { for(j=i;j<b;j++) { if(z[i]>z[j]) { strcpy(temp,x[i]); strcpy(x[i],x[j]); strcpy(x[j],temp); y=z[i]; z[i]=z[j]; z[j]=y; } } } for(i=0;i<b;i++) { printf("%s\n",x[i]); } } return 0; } /* Main.c: In function 'main': Main.c:6:18: error: conflicting types for 'y' char x[101][51],y[51],temp[51]; ^ Main.c:5:33: note: previous declaration of 'y' was here int a,b,c,d,i,j,m,n,z[101],e,q,y; ^ Main.c:10:4: warning: format '%s' expects argument of type 'char *', but argument 2 has type 'char (*)[51]' [-Wformat=] scanf("%s",&x[i]);//get字符串 ^ Main.c:41:8: error: assignment to expression with array type y=z[i]; ^ Main.c:43:11: warning: assignment makes integer from pointer without a cast z[j]=y; ^ Main.c:5:31: warning: unused variable 'q' [-Wunused-variable] int a,b,c,d,i,j,m,n,z[101],e,q,y; ^ Main.c:5:29: warning: unused variable 'e' [-Wunused-variable] int a,b,c,d,i,j,m,n,z[101],e,q,y; ^ Main.c:5:20: warning: unused variable 'n' [-Wunused-variable] int a,b,c,d,i,j,m,n,z[101],e,q,y; ^ Main.c:5:18: warning: unused variable 'm' [-Wunused-variable] int a,b,c,d,i,j,m,n,z[101],e,q,y; ^ Main.c:5:10: warning: unused variable 'c' [-Wunused-variable] int a,b,c,d,i,j,m,n,z[101],e,q,y; ^ */ |
Double click to view unformatted code.