| ||||||||||
| 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 | |||||||||
这两天真是见鬼了...麻烦路过的帮忙看一下程序的问题出在什么地方..思路很简单,就是所有even的赋零值,其余赋值出现次数+1
比较得最大值即为所求,
至于轻重,则用一BOOL数组表示,根据up,down而定
#include<iostream>
using namespace std;
int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
char a[12],b[12],c[6];
int con[12];
bool light[12];
int len;
for(int l=0;l<12;l++) {con[l]=1;light[l]=false;}
for(int t=0;t<3;t++){
scanf("%s%s%s",a,b,c);
int j;
len=strlen(a);
if(c[0]=='e') {
for(j=0;j<len;j++)
{
con[a[j]-'A']=0;
con[b[j]-'A']=0;
}
}
else if(c[0]=='u'){
for(j=0;j<len;j++)
{
light[b[j]-'A']=true;
if(con[a[j]-'A']>0) con[a[j]-'A']++;
if(con[b[j]-'A']>0) con[b[j]-'A']++;
}
}
else {
for(j=0;j<len;j++)
{
light[a[j]-'A']=true;
if(con[a[j]-'A']>0) con[a[j]-'A']++;
if(con[b[j]-'A']>0) con[b[j]-'A']++;
}
}
}
int max=1;
char res;
for(int k=0;k<12;k++) {if(max<con[k]) {max=con[k];res='A'+k;}}
cout<<res<<" is the counterfeit coin and it is ";
if(light[res-'A']) cout<<"light."<<endl;
else cout<<"heavy.\n";
}
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator