| ||||||||||
| 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?郁闷死了...#include <iostream.h>
void main(){
int n,i,j,k,Compare[3],a[12]={1,1,1,1,1,1,1,1,1,1,1,1},b[3][8],ItIs[3];
char c[3][8],Head[3];
cin>>n;
for(i=0;i<n;i++){
for(j=0;j<3;j++){
for(k=0;k<8;k++){
cin>>c[j][k];
b[j][k]=c[j][k]-'A';
}
cin>>Head[j];
cin.ignore(3,'\n');
switch(Head[j]){
case 'u':Compare[j]=-1;break;
case 'e':Compare[j]=0;break;
case 'd':Compare[j]=1;break;
}
}
for(j=0;j<12;j++){
a[j]=0;
for(k=0;k<3;k++){
if(a[b[k][0]]+a[b[k][1]]+a[b[k][2]]+a[b[k][3]]
-a[b[k][4]]-a[b[k][5]]-a[b[k][6]]-a[b[k][7]]+Compare[k]==0)
ItIs[k]=1;
else
ItIs[k]=0;
}
if(ItIs[0]&&ItIs[1]&&ItIs[2])
cout<<char(j+'A')<<" is the counterfeit coin and it is light."<<endl;
a[j]=1;
}
for(j=0;j<12;j++){
a[j]=2;
for(k=0;k<3;k++){
if(a[b[k][0]]+a[b[k][1]]+a[b[k][2]]+a[b[k][3]]
-a[b[k][4]]-a[b[k][5]]-a[b[k][6]]-a[b[k][7]]+Compare[k]==0)
ItIs[k]=1;
else
ItIs[k]=0;
}
if(ItIs[0]&&ItIs[1]&&ItIs[2])
cout<<char(j+'A')<<" is the counterfeit coin and it is heavy."<<endl;
a[j]=1;
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator