Cod sursa(job #365409)
| Utilizator | Data | 18 noiembrie 2009 16:58:26 | |
|---|---|---|---|
| Problema | Tablete | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva de probleme | Marime | 0.45 kb |
#include <fstream>
std::ifstream in("tablete.in");
std::ofstream out("tablete.out");
int main ()
{
int n,k,bol=0,i,j;
in>>n>>k;
for(i=0;i<=n;i++)
{ for(j=1;j<=n;j++)
{
if(j==k)
if((i*n+j)%2==0)
out<<i*n+j<<" ";
else
{
out<<i*n+j+1<<" ";
bol=i*n+j-1;
}
else
if(j==k-1&&bol)
{
out<<bol<<" ";
bol=0;
}
else
out<<i*n+j<<" ";
}
out<<'\n';
}
return 0;
} 