Advertisement
LilChicha174

Untitled

Apr 21st, 2022
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. typedef struct word {
  6.     char key[100];
  7.     char trans[100];
  8. } word;
  9.  
  10. int main() {
  11.     int cnt_word = 0;
  12.     word arr[100];
  13.     for (;;) {
  14.         word w;
  15.         scanf("%s", w.key);
  16.         if (strcmp(w.key, "ugabuga") == 0) {
  17.             break;
  18.         }
  19.         scanf("%s", w.trans);
  20.         arr[cnt_word] = w;
  21.         cnt_word++;
  22.     }
  23.     getc(stdin);
  24.     char or[10000];
  25.     fgets(or, 10000, stdin);
  26.     char *token;
  27.     token = strtok(or, " ");
  28.     while (token != NULL) {
  29.         int flag = 0;
  30.         for (int i = 0; i < cnt_word; i++) {
  31.             if (strcasecmp(token, arr[i].key) == 0){
  32.                 printf("%s ", arr[i].trans);
  33.                 flag = 1;
  34.                 break;
  35.             }
  36.         }
  37.         if(flag ==0){
  38.             printf("<unknown> ");}
  39.         token = strtok(NULL, " \n");
  40.     }
  41.     return 0;
  42. }
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement