Cod sursa(job #2466527)

Utilizator ContNou1Cont nou 1 ContNou1 Data 2 octombrie 2019 14:56:11
Problema Tablete Scor 0
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.73 kb
#include <iostream>
#include <fstream>
using namespace std;

int main()
{
    ///Faur Andreas; [email protected]; 10E;
    ifstream fin("tablete.in");
    fstream fout("tablete.out");
    int n, k, a[100][100], nr=1;
    fin >> n >> k;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            if(j==k && nr%2==1)
            {
                a[i][j]=nr+1;
                nr=nr+2;
            }
            if(j==k && nr%2==0 || j!=k)
            {
                a[i][j]=nr;
                nr++;
            }


        }
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
            fout << a[i][j] << " ";
        fout << endl;
    }
    return 0;
}