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 |
多栽点跟头,然后才会知道如何写程序In Reply To:哪位学长帮忙看一下病根在哪,总不忍心看着小弟含恨而去吧.(c语言) Posted by:20054959 at 2007-01-15 16:19:21 可以看出你对字符串的处理掌握得不够好 改一个字符就可以AC(自己去找错在哪里) 另外,缩进太乱 PS:祝你死得瞑目,安息吧,战友! > #include<stdio.h> > main() > {char str[100][50]; > int n,m,i,j,s[100]={0},p[100]={0},q=0,t,k; > scanf("%d%d",&n,&m); > if(m>0&&m<=100&&n>0&&n<=50) > { > for(i=0;i<m;i++) > scanf("%s",str[i]); > for(i=0;i<m;i++) //计算measure > for(j=0;j<n-1;j++) > for(k=j+1;k<n;k++) > if(str[i][j]>str[i][k]) > p[i]++; //第i行的measure是p[i] > for(i=0;i<m;i++) //(根据p[i]找出measure最小的行,输出并 {k=10000; //将其排除在外,然后再循环) > for(j=0;j<m;j++) > {if(k>p[j]&&s[j]==0) > {t=j;k=p[j]; > continue;} > if(k==p[i]&&s[t]==0&&q==0) > > {q=1; > continue; > } > } > printf("%s\n",str[t]); > s[t]=1; > q=0; > } > } > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator