Advertisement
NAbdulla

different word

May 16th, 2015
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. int main()
  5. {
  6.     int t, i, j, count, n, flag;
  7.     char grid[1005][105], str[105];
  8.     scanf("%d", &t);
  9.     while(t--){
  10.         scanf("%d", &n);
  11.         memset(grid, '\0', sizeof(grid));//setting all elements to NULL
  12.         count = 0;
  13.         for(i = 0; i < n; i++){
  14.             scanf("%s", str);
  15.             flag = 0;//no match found
  16.             for(j = 0; j < i; j++){
  17.                 if(strcmp(grid[j], str) == 0){
  18.                     flag = 1;// at least one match found
  19.                     break;
  20.                 }
  21.             }
  22.            
  23.             if(flag == 0){//if no match found
  24.                 strcpy(grid[j], str);
  25.                 count++;
  26.             }
  27.         }
  28.         printf("%d\n", count);
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement