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> #include <string.h> int main() { int length,num; char str[50][100]; char strtemp[100]; int i,j,m,temp=0,n=0; int sort[50]; scanf("%d %d",&length,&num); for(n=0;n<num;n++) { scanf("%s",str[n]); for(i=0;i<length-1;i++) { for(j=i+1;j<length;j++) { if(str[n][i]>str[n][j]) temp+=str[n][i]-str[n][j]; } } sort[n]=temp; temp=0; } for(i = 0; i < num-1; i++) { m = i; for(j = i+1; j < num; j++) if(sort[j] < sort[m]) m = j; if(i != m) { temp=sort[i]; sort[i]=sort[m]; sort[m]=temp; strcpy(strtemp,str[i]); strcpy(str[i],str[m]); strcpy(str[m],strtemp); } } for(i = 0; i < num-1; i++) { if(str[i]>str[i+1]) { strcpy(strtemp,str[i]); strcpy(str[i],str[i+1]); strcpy(str[i+1],strtemp); } } for(i = 0; i < num; i++) { printf("%s\n",str[i]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator