Cod sursa(job #640653)

Utilizator dutzulBodnariuc Dan Alexandru dutzul Data 26 noiembrie 2011 11:34:31
Problema Grozavesti Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.69 kb
#include <fstream>
using namespace std;
ifstream f("grozavesti.in");
ofstream g("grozavesti.out");
long long m, a[305][305],i,n,j,t,L,C;
int main()
{
    f>>n;
    for(i=1; i<=n; i++)
        for(j=1; j<=n; j++)
            f>>a[i][j];


    for(t=1; t<=n-1; t++)
    {
        m=1000005;
        for(i=t; i<=n; i++)
            for(j=t; j<=n; j++)
                if (a[i][j]<m)
                {
                    m=a[i][j];
                    L=i;
                    C=j;
                }
swap(a[t][t],a[L][C]);
        if (L!=t) g<<'L'<<" "<<t<<" "<<L<<'\n';
        if (C!=t) g<<'C'<<" "<<t<<" "<<C<<'\n';
    }




    f.close();
    g.close();
    return 0;
}