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:完美的程序,不过就是wa,请高手指教啊,救命,我交了好多次了这矬题

Posted by yangyong19880824 at 2008-07-05 10:56:29 on Problem 1099
In Reply To:完美的程序,不过就是wa,请高手指教啊,救命,我交了好多次了这矬题 Posted by:ljl08 at 2007-07-29 20:03:37
> #include <iostream>
> using namespace std;
> char square[50][43];
> bool linked[50][43];
> int a;
> void initial(int m){
> 	int i,j;
> 	for(i=0;i<50;i++)
> 		for(j=0;j<43;j++)
> 			square[i][j]=' ';
> 	for(i=0;i<50;i++)
> 		square[i][0]='*';
> 	for(i=0;i<m;i++){
> 		for(j=0;j<m;j++){
> 			square[4*i][4*j+1]='H';
> 			square[4*i][4*j+3]='O';
> 			if(i<m-1)square[4*i+2][4*j+3]='H';
> 		}
> 		square[4*i][4*j+1]='H';
> 		square[4*i][4*j+2]='*';
> 		square[4*i+1][4*j+2]='*';
> 		square[4*i+2][4*j+2]='*';
> 		square[4*i+3][4*j+2]='*';
> 	}
> 	for(i=0;i<50;i++){
> 		for(j=0;j<m;j++)
> 			linked[i][j]=false;
> 	}
> }
> void display(int m){
> 	int i=0,j=0;
> 	for(;i<4*m+3;i++)cout<<'*';
> 	cout<<endl;
> 	for(i=0;i<4*m-3;i++){
> 		for(j=0;j<4*m+3;j++)
> 			cout<<square[i][j];
> 		cout<<endl;
> 	}
> 	for(i=0;i<4*m+3;i++)cout<<'*';
> 	cout<<endl<<endl;
> }
> int input(int &m)
> {
> 	cin>>m;
> 	return m;
> }
> void main(){
> 	int i,j,m;
> 	int t=1;
> 	while(input(m)){
> 		initial(m);
> 		for(i=0;i<m;i++){
> 			for(j=0;j<m;j++){
> 				cin>>a;
> 				if(a==0){
> 					if(linked[4*i][4*j+1]){
> 						square[4*i][4*j+4]='-';
> 						linked[4*i][4*j+5]=true;
> 					}
> 					else{
> 						square[4*i][4*j+2]='-';
> 						linked[4*i][4*j+1]=true;
> 					}
> 					if(i==0||linked[4*i-2][4*j+3]){
> 						square[4*i+1][4*j+3]='|';
> 						linked[4*i+2][4*j+3]=true;
> 					}
> 					else{
> 						square[4*i-1][4*j+3]='|';
> 						linked[4*i-2][4*j+3]=true;
> 					}
> 				}
> 				if(a==1){
> 					square[4*i][4*j+2]='-';
> 					linked[4*i][4*j+1]=true;
> 					square[4*i][4*j+4]='-';
> 					linked[4*i][4*j+5]=true;
> 				}
> 				if(a==-1){
> 					square[4*i+1][4*j+3]='|';
> 					linked[4*i+2][4*j+3]=true;
> 					square[4*i-1][4*j+3]='|';
> 					linked[4*i-2][4*j+3]=true;
> 				}
> 			}
> 		}
> 		cout<<"Case "<<t<<':'<<endl<<endl;
> 		display(m);
>         t++;
> 	}
> }
> 

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