Advertisement
apl-mhd

boyOrGirl

Nov 6th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. #include <string.h>
  2. #include <stdio.h>
  3.  
  4.  
  5.  
  6. void boyOrGirl(char name[100]){
  7.  
  8.     int i,j,size, distincitLength =0,count;
  9.     size = strlen(name);
  10.  
  11.     char nameCopy[size];
  12.  
  13.     strcpy(nameCopy, name);
  14.  
  15.   //  printf("%s", nameCopy);
  16.  
  17.  
  18.     for(i = 0; i<size; i++){
  19.  
  20.         count =0;
  21.  
  22.         for(j=0; j<size; j++){
  23.  
  24.             if(nameCopy[i] == name[j]){
  25.  
  26.                 count++;
  27.                 name[j] = '0';
  28.  
  29.                 //printf("%c\n",name[j]);
  30.             }
  31.  
  32.         }
  33.  
  34.  
  35.         if(count>1){
  36.  
  37.             distincitLength += count-1;
  38.         }
  39.     }
  40.  
  41.  
  42.     //printf("%d\n", distincitLength);
  43.     if((size - distincitLength) % 2 ==0){
  44.  
  45.  
  46.         printf("CHAT WITH HER!");
  47.     }
  48.  
  49.     else{
  50.  
  51.         printf("IGNORE HIM!");
  52.  
  53.  
  54.     }
  55.  
  56. }
  57.  
  58.  
  59. int main(int argc, char *argv[])
  60. {
  61.    char name[100];
  62.  
  63.    gets(name);
  64.  
  65.    boyOrGirl(name);
  66.  
  67.  
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement