Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.23 KB | None | 0 0
  1. char** copy_text(char** Text,int n){
  2.     char *sent;
  3.     char **Text2= malloc(n* sizeof(char*));
  4.     for(int i=0;i<n;i++){
  5.         strcpy(sent,Text[i]);
  6.         Text2[i]=sent;
  7.     }
  8.     return Text2;
  9. }
  10.  
  11. void garbage_count(char** Text,int n) {
  12.     int Count = 0, Count_of_words = 0;
  13.     int size = 10;
  14.     char **Text2=copy_text(Text,n);
  15.     char **Words = malloc(10 * sizeof(char *));
  16.     char *STRtoK;
  17.     char *word;
  18.     for(int i=0;i<n;i++){
  19.         Count=0;
  20.         STRtoK=strtok(Text[i], " ,.");
  21.         while (STRtoK != NULL) {
  22.             if (Count_of_words == size) {
  23.                 size += 10;
  24.                 Words = realloc(Words, size * sizeof(char *));
  25.             }
  26.             word = to_lower(STRtoK);
  27.             if (strcmp(word, "garbage") == 0) {
  28.                 Count++;
  29.             }
  30.             STRtoK = strtok(NULL, " ,.");
  31.             Count_of_words++;
  32.         }
  33.         if (Count == 0) {
  34.             printf("Clear\n");
  35.         } else {
  36.             if (Count > 0 && Count < 6) {
  37.                 printf("Must be washed\n");
  38.             } else {
  39.                 printf("It's a dump!\n");
  40.             }
  41.  
  42.         }
  43.     }
  44.     print_text(Text2,n);
  45.     printf("\n");
  46.     print_text(Text,n);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement