Pagini recente » Cod sursa (job #594715) | Cod sursa (job #3031957) | Cod sursa (job #3163908) | Cod sursa (job #1744420) | Cod sursa (job #1213230)
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cstring>
using namespace std;
ifstream fin("restante.in");
ofstream fout("restante.out");
char word[36000][17];
void quickSort(int left, int right)
{
int i = left, j = right;
char tmp[17];
int pivot = (left + right) / 2;
while (i <= j)
{
while(strcmp(word[i],word[pivot]))
i++;
while(strcmp(word[j],word[pivot]))
j--;
if (i <= j)
{
strcpy(tmp, word[i]);
strcpy(word[i], word[j]);
strcpy(word[j], tmp);
i++;
j--;
}
};
if (left < j)
quickSort(left, j);
if (i < right)
quickSort(i, right);
}
void read()
{
int n, length;
fin >> n;
for(int i = 0; i < n; i++)
fin >> word[i];
for(int i = 0; i < n; i++)
{
length = strlen(word[i]);
sort(word[i], word[i] + length);
}
quickSort(0, n-1);
int x = 0;
for(int i = 0; i < n - 1; i++)
{
if(strcmp(word[i],word[i+1])) x += 1;
}
fout << x;
}
int main()
{
read();
return 0;
}