Pagini recente » Cod sursa (job #399942) | Cod sursa (job #2091578) | Cod sursa (job #380630) | Cod sursa (job #598661) | Cod sursa (job #782323)
Cod sursa(job #782323)
#include <fstream>
#define MAX 512
#define INF 0x3f3f3f3f
using namespace std;
int c[MAX][MAX], moves[MAX][2], ind, n;
int main()
{
ifstream in("grozavesti.in");
in>>n;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= n; j++)
in>>c[i][j];
for(int i = 1; i <= n; i++)
{
int minim = INF, lMin, cMin;
for(int j = i; j <= n; j++)
{
if(c[j][j] < minim)
{
lMin = j;
cMin = j;
minim = c[j][j];
}
}
if(lMin != i && cMin != i)
{
swap(c[i][i], c[lMin][cMin]);
moves[++ind][0] = i; moves[ind][1] = lMin;
}
}
ofstream out("grozavesti.out");
out<<2 * ind<<"\n";
for(int i = 1; i <= ind; i++)
out<<"L "<<moves[i][0]<<" "<<moves[i][1]<<"\n"<<"C "<<moves[i][0]<<" "<<moves[i][1]<<"\n";
out.close();
return 0;
}