求助
查看原帖
求助
1304507
ljx_17777楼主2024/6/28 14:48

有大佬能帮我看看这C++代码错哪儿了吗?

#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(j==1||j==n){//先是最高级'|' 
				cout<<'|';
			}
			else{
				if(i==1||i==n){//围上边框 
					cout<<'-';
				}
				else{
					if(j!=(n+1)/2&&i!=(n+1)/2){//非横或竖中线 
						cout<<'x';
					}
					else{
						if(j==(n+1)/2&&i==(n+1)/2){//在中心点上 
							cout<<'x';
						}
						else{
							if(j==(n+1)/2){
								cout<<'|';
							}
							else{
								if(i==(n+1)/2){
									cout<<'-';
								}
							}
						}
					}
				}
			}
		}
		cout<<endl; 
	}
	
	
	
	return 0;
} 

全WA不懂错在哪儿。

2024/6/28 14:48
加载中...