Pagini recente » Cod sursa (job #536496) | Cod sursa (job #715972) | Cod sursa (job #81435) | Cod sursa (job #2183432) | Cod sursa (job #337136)
Cod sursa(job #337136)
#include<stdio.h>
#include <cstdio>
#include<algorithm>
#include<string.h>
#define dim 36001
#define cif 17
using namespace std;
char s[cif];
int n,max;
char aux, A[dim][cif];
int O[dim];
/*inline int cmp (const void *a, const void *b)
{
//int aa = *(int *)a;
// int bb = *(int *)b;
return (A[*(int *)a] < A[*(int *)b]) ? -1 : (A[*(int *)a] > A[*(int *)b]) ? 1 : 0;
}
*/
int main()
{ int i, j, m, k,max,ok;
FILE *f = fopen("restante.in", "r");
FILE *g = fopen("restante.out", "w");
fscanf(f, "%d", &n);
max = 0;
for(i = 1; i <= n; i++)
{
fscanf(f, "%s", &s);
m = strlen(s);
if(m > max) max = m;
for(j = 0; j < m; j++)
A[i][j] = s[j];
sort(A[i], A[i]+m);
}
//qsort(A[1], A[n], sizeof(int), cmp);
for(i = 1; i <= n-1; i++)
for(j = i+1; j <= n; j++)
{
ok = memcmp(A[i],A[j], sizeof(A));
if(ok > 0) {memcpy(s, A[i], max); memcpy(A[i], A[j], max); memcpy(A[j], s, max);}
}
k = 0;
for(i = 2; i <= n; i++)
{ok = memcmp(A[i], A[i-1], max);
if(ok==0) k++;
}
fprintf(g, "%d\n", n-k*2);
fclose(f);
fclose(g);
return 0;
}