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 |
为什么一直WA。。。。#include <stdio.h> #include <stdlib.h> #include <string.h> int main(int argc, char *argv[]) { int len,n,i,j,k,count; char s[52][101]={0}; char *p[100],*temp; /*输入并计算逆序*/ scanf ("%d%d",&len,&n); getchar(); for (i=0;i<n;i++) { gets(s[i]); p[i]=s[i]; count=0; for (j=0;j<len-1;j++) { for (k=j+1;k<len;k++) if (s[i][j]>s[i][k]) count++; } s[i][51]=count; } /*逆序数排序*/ for (i=1;i<n;i++) for (j=0;j<n-i;j++) { if (p[j][51]>p[j+1][51]) { temp=p[j]; p[j]=p[j+1]; p[j+1]=temp; } } /*输出*/ for (i=0;i<n;i++) puts(p[i]); 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