Pagini recente » Cod sursa (job #2176011) | Cod sursa (job #269632) | Cod sursa (job #1002262) | Cod sursa (job #2927517) | Cod sursa (job #2181972)
#include <fstream>
using namespace std;
ifstream fin ("tablete.in");
ofstream fout ("tablete.out");
int i,n,k,x,j,v[1010][1010];
int main (){
fin>>n>>k;
if(k%2==0){
x=2;
for(i=1;i<=n;i++)
for(j=2;j<=n;j=j+2)
{
v[i][j]=x;
x=x+2;
}
x=1;
for(i=1;i<=n;i++)
for(j=1;j<=n;j=j+2)
{
v[i][j]=x;
x=x+2;
}
}
else{
x=2;
for(i=1;i<=n;i++)
for(j=1;j<=n;j=j+2)
{
v[i][j]=x;
x=x+2;
}
x=1;
for(i=1;i<=n;i++)
for(j=2;j<=n;j=j+2){
v[i][j]=x;
x=x+2;
}
}
for(i=1;i<=n;i++){
for(j=1;j<=n;j++)
fout<<v[i][j]<<" ";
fout<<"\n";
}
return 0;
}