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 |
Re:不解啊,求大牛In Reply To:不解啊 Posted by:2009302513 at 2011-06-23 16:21:52 > 程序结果正确但就是不过,还有错误,真是伤脑筋 #include<stdio.h> #include<string.h> typedef struct DNA { char str[100]; int count; }DNA; int main() { char ch; int i; int j; int k; int m,n; DNA a[1000]={{'\0'},{0}}; DNA t={{'\0'},{0}}; scanf("%d%d",&m,&n); ch=getchar(); for(i=0;i<n;i++) { gets(a[i].str); a[i].count=0; } printf("\n"); for(i=0;i<n;i++) { for(j=0;j<m;j++) { for(k=1+j;k<m;k++) { if(a[i].str[k]<a[i].str[j]) { a[i].count++; } } } } for(i=0;i<n;i++) { for(j=0;j<n-i-1;j++) { if(a[j].count>a[j+1].count) { strcpy(t.str,a[j].str); t.count=a[j].count; strcpy(a[j].str,a[j+1].str); a[j].count=a[j+1].count; strcpy(a[j+1].str,t.str); a[j+1].count=t.count; } } } for(i=0;i<n;i++) { printf("%s\n",a[i].str); } return(0); } 错在哪里啊? Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator