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 |
完美的程序,不过就是wa,请高手指教啊,救命,我交了好多次了这矬题#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator