Cod sursa(job #2455335)
| Utilizator | Data | 11 septembrie 2019 13:20:58 | |
|---|---|---|---|
| Problema | Tablete | Scor | 10 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.53 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream in ("tablete.in");
ofstream out ("tablete.out");
int n,k,h,i,j,s,f;
int main()
{
in>>n;
in>>k;
if(n%2==0&&k%2==0)
{h=1;for(i=1;i<=n;i++)
{for(j=1;j<=n;j++,h++)out<<h<<" ";
out<<"\n";
}
}
if(n%2==0&&k%2==1)
{s=1;
f=n*2;
for(i=0;i<n;i=i+2)
{for(j=s+1;j<s+n;j++)out<<j<<" ";
out<<n*2+s-1<<"\n";
out<<"1 ";for(j=s+n;j+1<s+n*2;j++)out<<j<<" ";
out<<"\n";
s=s+n*2; }
}
return 0;
}
