相異なる文の種類の数(c言語の場合)
#include <stdio.h> #include <math.h> #include <string.h> int cmp(const char *a,const char *b){ return strcmp(b,a); } int main(void){ char buf[1000]; FILE *stream; char string[10001][70]; int i = 0; int j = 0; int chohuku =0; while(fgets(buf, 1000,stdin) != NULL){ strcpy(string[i],buf); i++; } qsort(string,i,70,(int (*)(const void*,const void*))cmp); for(j =0 ; j< i; j++){ if(strcmp(string[j] ,string[j+1])== 0){ chohuku++; } } printf("%d\n",j-chohuku-1); return 0; }