Cod sursa(job #1815581)

Utilizator V0RT3N1XKing Tudy V0RT3N1X Data 25 noiembrie 2016 14:28:38
Problema Cutii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.89 kb
#include <iostream>
#include <fstream>
#include <math.h>

using namespace std;
unsigned n, t, x, y, z, i, gasit, nr, inv;

ifstream f1("cutii.in");
ofstream f2("cutii.out");

int main()
{
    f1 >> n;
    f1 >> t;
    unsigned long c[n];
    while(t>0)
    {
        for(i=0;i<n;i++)
        {
            f1 >> x;
            f1 >> y;
            f1 >> z;
            c[i]=x+y+z;
        }
        do
        {
            inv = 0;
            for(i=0;i<n-1;i++)
                if(c[i]>c[i+1])
                {
                    swap(c[i],c[i+1]);
                    inv = 1;
                }
        }while(inv);
        for(i=0;i<n && !gasit;i++)
        {
            if(c[i]<c[i+1])
                nr++;
            else
                gasit = 1;
        }
        f2 << nr << endl;
        gasit = 0;
        nr = 0;
        t--;
    }
    return 0;
}