Cod sursa(job #3337356)
| Utilizator | Data | 27 ianuarie 2026 12:32:44 | |
|---|---|---|---|
| Problema | Tablete | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 1.69 kb |
#include <fstream>
using namespace std;
ifstream cin("tablete.in");
ofstream cout("tablete.out");
int main()
{
int n,c,val1=2,val2=1,i,j;
cin>>n>>c;
/*if(n%2==0){
if(col%2==0){
for(i=1;i<=n;i++){
for(j=1;j<=n;j++,s++)
cout<<s<<' ';
cout<<'\n';
}
}
else{
if(col<n){
for(i=1;i<=n;i++){
for(j=1;j<col;j++,s++)
cout<<s<<' ';
cout<<s+2;
s++;
cout<<s;
s++;
for(j=col+2;j<=n;j++,s++)
cout<<s<<' ';
cout<<'\n';
}
}
else{ ///col=n
for(i=1;i<=n;i++){
for(j=1;j<n-1;j++,s++)
cout<<s<<' ';
cout<<s+2;
s++;
cout<<s;
s++;
for(j=col+2;j<=n;j++,s++)
cout<<s<<' ';
cout<<'\n';
}
}
}
}*/
for(i=1;i<=n;i++){
for(j=1;j<=n;j++){
if(j==c){
cout<<val1<<' ';;
if(val2%2==1){
val1=val2+1;
val2+=2;
}
else{
val1+=2;
val2++;
}
}
else{
cout<<val2<<' ';
val2++;
}
}
cout<<'\n';
}
return 0;
}
