#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

  • @ 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