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

now show me in what way you will die

Posted by c0500448264 at 2005-07-08 15:23:23 on Problem 1013
In Reply To:我快死了,救救我的程序,(附)(救人一命,胜造七级浮屠) Posted by:linmeng at 2005-07-08 15:19:35
> #include <iostream.h>
> #include <string.h>
> int n,k;
> int q[200],up,w[200];//up 表示天平不平了几次
> int main()
>  {
>   memset(q,0,sizeof(q));
>   memset(w,0,sizeof(w));
>   cin>>n;
>   flag=1;up=0;
>   int i;
>   for (i=1;i<=n;i++)
>   {
>    for (k=1;k<=3;k++)
>    {
>     int j;
>     int temp[200];char st[200];    
>     int p;memset(temp,0,sizeof(temp));
> 
>     cin>>st;p=strlen(st);
>     for (j=0;j<=p-1;j++) temp[j+1]=st[j]-'A'+1;
>     cin>>st;
>     for (j=0;j<=p-1;j++) temp[j+1+p]=st[j]-'A'+1;
> 
>     char ch[10];
>     cin>>ch;
>     if (!strcmp(ch,"even"))
>                  {
>                   for (j=1;j<=p*2;j++) q[temp[j]]=-1;
>                  }
>             else {
>                   flag=0;up++;
>                   for (j=1;j<=p*2;j++)
>                    if (q[temp[j]]!=-1) {
>                                         q[temp[j]]++;
>                                         if (!strcmp(ch,"up")) 
>                                                      {
>                                                       if (j>p) w[temp[j]]=-1; else w[temp[j]]=+1;
>                                                      }
>                                         if (!strcmp(ch,"down"))
>                                                      { 
>                                                       if (j>p) w[temp[j]]=+1; else w[temp[j]]=-1;
>                                                      } 
>                                        } 
>                  }
>    }      
>    for (i=1;i<=12;i++)
>     if (q[i]==up) {
> 		   cout<<(char)(i+(int)'A'-1)<<" is the counterfeit coin and it is ";
> 		   if (w[i]>0) cout<<"heavy."<<endl;
> 			 else cout<<"light."<<endl;
>                   }
>   }  
>   return 0;
>  }
>                             
>   

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