Pagini recente » Cod sursa (job #1799249) | Cod sursa (job #791343) | Cod sursa (job #763989) | Autentificare | Cod sursa (job #127545)
Cod sursa(job #127545)
#include <stdio.h>
#include <string.h>
#define Nmax 36004
#define Lmax 16
int N,nr,i;
char s[Nmax][Lmax];
void citire()
{
freopen("restante.in","r",stdin);
scanf("%d",&N);
for (i=1;i<=N;++i)
scanf("%s\n",&s[i]);
fclose(stdin);
}
void bulansort(int ind)
{
int ok=1,L,i;
char aux;
L=strlen(s[ind]);
while (ok)
{
ok=0;
for (i=0;i<L-1;++i)
if (s[ind][i]>s[ind][i+1])
{
ok=1;
aux=s[ind][i];
s[ind][i]=s[ind][i+1];
s[ind][i+1]=aux;
}
}
}
void qsort(int st,int dr)
{
int i=st,j=dr;
char m[Lmax],aux[Lmax];
memcpy(m,s[(st+dr)>>1],sizeof(s[(st+dr)>>1]));
while (i<=j)
{
while (strcmp(m,s[i])>0) ++i;
while (strcmp(s[j],m)>0) --j;
if (i<=j)
{
memcpy(aux,s[i],sizeof(s[i]));
memcpy(s[i],s[j],sizeof(s[j]));
memcpy(s[j],aux,sizeof(aux));
++i,--j;
}
}
if (i<dr) qsort(i,dr);
if (st<j) qsort(st,j);
}
int main()
{
citire();
for (i=1;i<=N;++i)
bulansort(i);
qsort(1,N);
i=1;
while (i<=N)
{
if (strcmp(s[i],s[i+1])==0)
{
while (strcmp(s[i],s[i+1])==0)
++i;
}
else ++nr;
++i;
}
freopen("restante.out","w",stdout);
printf("%d",nr);
fclose(stdout);
return 0;
}