- 【例38.3】 X战警
111
- 2025-3-24 17:37:00 @
#include<bits/stdc++.h>
using namespace std;
int n,l,r;
int main(){
cin>>n;
l=1,r=n;
for(int i=1;i<=n;i++,l++,r--){
for(int j=1;j<=n;j++){
if(j==l || j==r){
cout<<'X';
}
else{
cout<<' ';
}
}
cout<<endl;
}
return 0;
}
1 comments
-
xiance069 LV 4 @ 2025-3-24 17:43:49
#include<bits/stdc++.h> using namespace std; int n,l,r; int main(){ cin>>n; l=1,r=n; for(int i=1;i<=n;i++,l++,r--){ for(int j=1;j<=n;j++){ if(jl || jr){ cout<<'X'; } else{ cout<<' '; } } cout<<endl; } return 0; }
- 1
Information
- ID
- 145
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- # Submissions
- 36
- Accepted
- 14
- Uploaded By