Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
我的运行对了,为什么提交compile error? help!#include <stdio.h> #include <stdlib.h> typedef struct{ char a[100]; int r; }DNA; int athwart(char a[],int N)//统计每行的逆序数 { int count=0; int i=0; while(i<N) { int j=i+1; while(j<N) { if(a[i]>a[j]) count++; j++; } i++; } return count; } int main(int argc, char *argv[]) { int n,m; scanf("%d %d",&n,&m); DNA d[m]; int i=0; while(i<m) { scanf("%s",d[i].a); d[i].r=athwart(d[i].a,n); i++; } int j=0;//将每行的逆序数从小到大排序 while(j<m) { DNA y; int s=0; while(s<m-j) { if(d[s].r>d[s+1].r) { y=d[s]; d[s]=d[s+1]; d[s+1]=y; } s++; } j++; } int q=0;//输出 while(q<m) { printf("%s\n",d[q].a); q++; } system("PAUSE"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator