Cod sursa(job #246375)

Utilizator ooctavTuchila Octavian ooctav Data 20 ianuarie 2009 19:35:44
Problema Cutii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.73 kb
// cutii.cpp : Defines the entry point for the console application.
//

#include <stdio.h>
#include <stdlib.h>
int e[3504];
int comparare(const void * a,const void * b)
{
	return(*(int*)a - *(int*)b);
}
int main()
{
	int n,t,i,j,l;
	int a,b,c,d=0;
	FILE *f1,*f2;
	f1=fopen("cutii.in","r");
	f2=fopen("cutii.out","w");
	fscanf(f1,"%d %d",&n,&t);
	for(i=1;i<=t;i++)
	{
		for(j=1;j<=n;j++)
		{
			fscanf(f1,"%d %d %d",&a,&b,&c);
			a=a*100+b*10+c;
			e[j]=a;
		}
		qsort(e,n+1,sizeof(int),comparare);
		for(j=1;j<=n;j++)
			for(l=j+1;l<=n;l++)
				if(e[j]%100<=e[l]%100)
					if(e[j]%10<=e[l]%10)
						d++;
		for(j=1;j<=n;j++)
			e[j]=0;
		fprintf(f2,"%d\n",d);
		d=0;
	}
	fclose(f1);
	fclose(f2);
	return 0;
}