Cod sursa(job #273412)
Utilizator | Data | 8 martie 2009 15:36:55 | |
---|---|---|---|
Problema | Tablete | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.45 kb |
#include<iostream>
using namespace std;
int main()
{
freopen("tablete.in","r",stdin);
freopen("tablete.out","w",stdout);
int n, k, i, j, c;
cin>>n>>k;
for(c=1,i=0;i<n;i++)
{
for(j=0;j<k-2;j++)cout<<c++<<" ";
if(c%2&&k!=1)cout<<c++<<" "<<c++<<" ";
else cout<<++c<<" "<<(c++)-1<<" ";
for(j=k;j<n;j++)cout<<c++<<" ";
cout<<endl;
}
}