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 |
为什么不能用字符串输出?#include<stdio.h> int main() { int m,n,i,j,k,sum[100]; char arry[100][50]; scanf("%d %d",&n,&m); for(i=0;i<m;i++) scanf("%s",arry[i]); for(i=0;i<m;i++) { sum[i]=0; for(j=0;j<n-1;j++) for(k=j+1;k<n;k++) if(arry[i][j]>arry[i][k]) sum[i]++; } for(i=0;i<m;i++) { int temp=10000; int tempsig=0; for(j=0;j<m;j++) if(sum[j]<temp) { temp=sum[j]; tempsig=j; } sum[tempsig]=10001; printf("%s\n",arry[tempsig]); } } 这样输出字符串wrong answer 如果输出改为 for(i=0;i<m;i++) { int temp=10000; int tempsig=0; for(j=0;j<m;j++) if(sum[j]<temp) { temp=sum[j]; tempsig=j; } sum[tempsig]=10001; for(j=0;j<n;j++) printf("%c",arry[tempsig][j]); printf("\n"); } 就对了 why??? Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator