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

高手看看,数组也没越界为什么老是RE?郁闷死了...

Posted by cpp0600548274 at 2006-03-01 19:54:39 on Problem 1013
#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:
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