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 |
somebody run this code, and u will see that my sol is right, but it gave me wrong answer, and i test it with the code that i sent before#include<iostream> using namespace std; int main() { int t,n,i,j,k,n_2; cin>>t; for(i=0;i<t;i++) { cin>>n; cout<<n<<endl; n_2=n/2; if(n%6==2) { for(j=1;j<n;j+=2) { for(int l=0;l<n*2+1;l++) cout<<"-"; cout<<endl; for(int l=0;l<j;l++) cout<<"| "; cout<<"|*"; for(int l=j+1;l<n;l++) cout<<"| "; cout<<"|"<<endl; } j=n-4; for(k=0;k<n_2;k++) { for(int l=0;l<n*2+1;l++) cout<<"-"; cout<<endl; for(int l=0;l<j%n;l++) cout<<"| "; cout<<"|*"; for(int l=j%n+1;l<n;l++) cout<<"| "; cout<<"|"<<endl; j+=2; } for(int l=0;l<n*2+1;l++) cout<<"-"; cout<<endl; continue; } if(n%2==0) { for(int j=1;j<n;j+=2) { for(int l=0;l<n*2+1;l++) cout<<"-"; cout<<endl; for(int l=0;l<j;l++) cout<<"| "; cout<<"|*"; for(int l=j+1;l<n;l++) cout<<"| "; cout<<"|"<<endl; } for(int j=0;j<n;j+=2) { for(int l=0;l<n*2+1;l++) cout<<"-"; cout<<endl; for(int l=0;l<j;l++) cout<<"| "; cout<<"|*"; for(int l=j+1;l<n;l++) cout<<"| "; cout<<"|"<<endl; } for(int l=0;l<n*2+1;l++) cout<<"-"; cout<<endl; continue; } if(n%6==3) { int j; for(j=0;j<n;j+=2) { for(int l=0;l<n*2+1;l++) cout<<"-"; cout<<endl; for(int l=0;l<j;l++) cout<<"| "; cout<<"|*"; for(int l=j+1;l<n;l++) cout<<"| "; cout<<"|"<<endl; } j=n-4; for(int l=0;l<j%n;l++) { for(int l=0;l<n*2+1;l++) cout<<"-"; cout<<endl; for(int l=0;l<j%n;l++) cout<<"| "; cout<<"|*"; for(int l=j%n+1;l<n;l++) cout<<"| "; cout<<"|"<<endl; } for(int l=0;l<n*2+1;l++) cout<<"-"; cout<<endl; continue; } for(j=0;j<n;j+=2) { for(int l=0;l<n*2+1;l++) cout<<"-"; cout<<endl; for(int l=0;l<j;l++) cout<<"| "; cout<<"|*"; for(int l=j+1;l<n;l++) cout<<"| "; cout<<"|"<<endl; } for(int j=1;j<n;j+=2) { for(int l=0;l<n*2+1;l++) cout<<"-"; cout<<endl; for(int l=0;l<j;l++) cout<<"| "; cout<<"|*"; for(int l=j+1;l<n;l++) cout<<"| "; cout<<"|"<<endl; } for(int l=0;l<n*2+1;l++) cout<<"-"; cout<<endl; cout<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator