zono

Курсова задача.

May 27th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.04 KB | None | 0 0
  1. /**
  2.     Сваляш си codeblocks http://www.codeblocks.org/ от тук
  3.     и го инсталираш. След това от File -> New избираш
  4.     нов проект, следваш wizard-a и и избираш C проект.
  5.     Това просто го слагаш в main.c и цъкаш горе на
  6.     менюто Build and Run. Може да търси в речника, но
  7.     както виждаш там са само три думи:
  8.     "table", "shoe" и "language". Пита те за
  9.     думата и ако я намери изкарва значението и
  10.     ако не я намери изкарва, че не е намерена.
  11.     Това е. Можеш да си добавяш нови думи и значения, но
  12.     не забравяй да увеличаваш тази цифра тук:
  13.     *wordsCatalog[3]
  14.  **/
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <stdbool.h>
  18. #define SIZE_OF_ARRAY(x)  (sizeof(x) / sizeof(x[0]))
  19.  
  20. int main()
  21. {
  22.  
  23.     char searchWord[65];
  24.     bool searchTermIsFound = false;
  25.     int i;
  26.  
  27.     const char *wordsCatalog[3][2] = {
  28.        {"table", "a piece of furniture having a smooth flat top that is usually supported by one or more vertical legs"},
  29.        {"shoe", "footwear shaped to fit the foot (below the ankle) with a flexible upper of leather or plastic and a sole and heel of heavier material"},
  30.        {"language", "a systematic means of communicating by the use of sounds or conventional symbols"}
  31.     };
  32.  
  33.     printf("Please. Type a word whose meaning you want to look in the dictionary: \n");
  34.     scanf("%s", searchWord);
  35.  
  36.     for (i = 0 ; i < SIZE_OF_ARRAY(wordsCatalog); i++) {
  37.          if (strcmp(searchWord, wordsCatalog[i][0]) == 0) {
  38.             printf("Meaning of the word:\n%s", wordsCatalog[i][1]);
  39.             searchTermIsFound = true;
  40.             break;
  41.          }
  42.     }
  43.  
  44.     if (searchTermIsFound == false) {
  45.        printf("Search term was not found in the dictionary.\n");
  46.     }
  47.  
  48.     getchar();
  49.     return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment