Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:求大牛帮忙看下哪错了,为什么老是WA?C语言

Posted by 00548064 at 2007-01-20 17:00:40 on Problem 1007
In Reply To:求大牛帮忙看下哪错了,为什么老是WA?C语言 Posted by:20054953 at 2007-01-18 20:11:09
> #include"stdio.h"
> #include <stdlib.h>
> #include"string.h"
> main()
> {int n,m,i,j,k,c;
>  long sum[51],d[51];
>  char a[100][51];
>  scanf("%d%d",&n,&m);
>  for(i=0;i<m;i++)
>          scanf("%s",&a[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(a[i][j]>a[i][k])
>                  sum[i]=sum[i]+1;
>       }
>  for(i=0;i<m;i++)
>      d[i]=sum[i];
>  for(i=1;i<m;i++)
>      for(j=0;j<m-i;j++)
>          if(d[j]>d[j+1])
>            {c=d[j];
>             d[j]=d[j+1];
>             d[j+1]=c;
>             }
>  for(i=0;i<m;i++)
>     {if(d[i]==d[i+1]) continue;
>      for(j=0;j<m;j++)
>          if(d[i]==sum[j])
>             printf("%s\n",a[j]);
>      }     
>  }
好像是范围不对,仔细看一下题

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator