1 solutions

  • 0
    @ 2025-12-3 17:16:04

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int N,t=1;
    int main()
    {
        cin>>N;
        for(int j=1;j<=N;j++)
        {
        	if(j%2==1){
        		for(int i=t;i<t+N;i++) cout<<i<<" ";
        		t+=N;
        		cout<<endl;
        	}
        	else{
        		for(int i=t+N-1;i>=t;i--) cout<<i<<" ";
        		t+=N;
        		cout<<endl;
        	}
        }
    }
    
    • 1

    Information

    ID
    972
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By