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

WA啊,哪位好心的大哥能指点一下啊!万分感谢!

Posted by jiabiao at 2006-04-18 13:07:48 on Problem 2062
#include<stdio.h>
int main()
{
  char a[26][2],m[26][2];
  int b[26],c[26],n[26],p[26];
  int flag[26];
  int i,j,k,N,num,temp,data,point;
  scanf("%d",&N);
  for(i=0;i<N;i++)
  {
    point=0;
    for(j=0;j<26;j++)
    flag[j]=0;
    scanf("%d",&num);
    for(j=0;j<num;j++)
    {
      scanf("%s",a[j]);
      if(a[j][1]=='H')
      c[j]=4;
      if(a[j][1]=='S')
      c[j]=3;
      if(a[j][1]=='D')
      c[j]=2;
      if(a[j][1]=='C')
      c[j]=1;
      if(a[j][0]=='A')
      b[j]=14;
      if(a[j][0]>'1'&&a[j][0]<='9')
      b[j]=a[j][0]-48;
      if(a[j][0]>'9')
      {
        if(a[j][0]=='T')
        b[j]=10;
        if(a[j][0]=='J')
        b[j]=11;
        if(a[j][0]=='Q')
        b[j]=12;
        if(a[j][0]=='K')
        b[j]=13;
      }
    }
    for(j=0;j<num;j++)
    {
      scanf("%s",m[j]);
      if(m[j][1]=='H')
      p[j]=4;
      if(m[j][1]=='S')
      p[j]=3;
      if(m[j][1]=='D')
      p[j]=2;
      if(m[j][1]=='C')
      p[j]=1;
      if(m[j][0]=='A')
      n[j]=14;
      if(m[j][0]>'1'&&m[j][0]<='9')
      n[j]=m[j][0]-48;
      if(m[j][0]>'9')
      {
        if(m[j][0]=='T')
        n[j]=10;
        if(m[j][0]=='J')
        n[j]=11;
        if(m[j][0]=='Q')
        n[j]=12;
        if(m[j][0]=='K')
        n[j]=13;
      }
    }
    for(j=0;j<num-1;j++)
      for(k=0;k<num-1;k++)
      {
        if(b[k+1]<b[k])
        {
          temp=b[k];
          b[k]=b[k+1];
          b[k+1]=temp;
          data=c[k];
          c[k]=c[k+1];
          c[k+1]=data;
        }
        if(b[k+1]==b[k])
        {
          if(c[k+1]<c[k])
          {
            temp=b[k];
            b[k]=b[k+1];
            b[k+1]=temp;
            data=c[k];
            c[k]=c[k+1];
            c[k+1]=data;
          }
        }
      }
    for(j=0;j<num-1;j++)
      for(k=0;k<num-1;k++)
      {
        if(n[k+1]<n[k])
        {
          temp=n[k];
          n[k]=n[k+1];
          n[k+1]=temp;
          data=p[k];
          p[k]=p[k+1];
          p[k+1]=data;
        }
        if(n[k+1]==n[k])
        {
          if(p[k+1]<p[k])
          {
            temp=n[k];
            n[k]=n[k+1];
            n[k+1]=temp;
            data=p[k];
            p[k]=p[k+1];
            p[k+1]=data;
          }
        }
      }
    for(j=0;j<num;j++)
      for(k=0;k<num;k++)
      {
         if(n[j]>b[k]&&flag[k]!=1)
         {
           point++;
           flag[j]=1;
           break;
         }
         if(n[j]==b[k]&&flag[k]!=1)
         {
            if(p[j]>c[j])
            {
              point++;
              flag[j]=1;
              break;
            }
         }
      }
      printf("%d\n",point);
  }
}

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