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

五十题纪念,贴个代码……个人能力有限,水平不高,代码也不高,只是借个地方贴代码……

Posted by 15914304086 at 2011-12-10 14:22:12 on Problem 1013
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main()
{int n,g[12][3],i,la,lb,k;
 string a,b,c;
 cin>>n;
 while (n--)
 {for (i=0;i<12;i++)
   for (k=0;k<3;k++)
	    g[i][k]=-2;
  for (i=0;i<=2;i++)
  {cin>>a>>b>>c;
  if (c=="even") {lb=la=a.length();
                  while (la) g[a[--la]-65][i]=0;
				  while (lb) g[b[--lb]-65][i]=0;}
  else {if (c=="down") {c=a;a=b;b=c;}
        lb=la=a.length();
		while (la) g[a[--la]-65][i]=1;
		while (lb) g[b[--lb]-65][i]=-1;
		for (k=0;k<12;k++) if (g[k][i]==-2) g[k][i]=0;}
  }
  for (k=0;k<12;k++)
	  if (g[k][0]*g[k][1]*g[k][2]) if (g[k][1]*g[k][2]!=-1 && g[k][1]*g[k][0]!=-1 && g[k][2]*g[k][0]!=-1)
	                               {cout<<char(k+65)<<" is the counterfeit coin and it is ";
                                    if (g[k][0]==-1 || g[k][1]==-1 ||g[k][2]==-1) cout<<"light."<<endl;
									else cout<<"heavy."<<endl;
									break;}
 }
 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