| ||||||||||
| 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 | |||||||||
Re:cin与scanf有什么区别?In Reply To:Re:cin与scanf有什么区别? Posted by:noskill at 2005-03-12 01:02:21 似乎不是这个原因吧。这题我用iostream过了……
#include<iostream.h>
#include<string.h>
/*#include<fstream.h>
#define cin fin
ifstream fin("1184.txt");
*/
char str1[3][20],str2[3][20],str3[3][5];
int len[3];
int rec[13];
int judge()
{
int i,j; int left,right;
for(i=0;i<=2;i++)
{
left=0; right=0;
for(j=0;j<=len[i]-1;j++)
{
left=left+rec[str1[i][j]-'A'+1];
right=right+rec[str2[i][j]-'A'+1];
}
if(left!=right && strcmp(str3[i],"even")==0) return 0;
if(left<=right && strcmp(str3[i],"up")==0) return 0;
if(left>=right && strcmp(str3[i],"down")==0) return 0;
}
return 1;
}
int main()
{
int cases; int ct,i;
cin>>cases;
for(;cases>0;cases--)
{
for(ct=0;ct<=2;ct++)
{
cin>>str1[ct]>>str2[ct]>>str3[ct];
len[ct]=strlen(str1[ct]);
}
for(i=1;i<=12;i++)
rec[i]=1;
for(i=1;i<=12;i++)
{
rec[i]=2;
if(judge())
{
cout<<char('A'+i-1)<<" is the counterfeit coin and it is heavy.\n";
break;
}
rec[i]=0;
if(judge())
{
cout<<char('A'+i-1)<<" is the counterfeit coin and it is light.\n";
break;
}
rec[i]=1;
}
}
return 1;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator