Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.68 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. //Створити масив структур, який містить відомості щодо словника. Кожна структура містить поля: слово і його кілька перекладів.
  4. //Реалізувати виведення всього словника, переклад з української на англійську, з англійської на українську.
  5. struct Dictionary {
  6.     string word_ukr;
  7.     string word_eng1;
  8.     string word_eng2;
  9. };
  10.  
  11. void showAll(Dictionary[], int);
  12.  
  13. void showAll(Dictionary a[], int n) {
  14.     for (int i = 0; i < n; i++) {
  15.         cout << "Слово "<< i+1 << ":" << endl <<a[i].word_ukr << endl << a[i].word_eng1 << endl << a[i].word_eng2 << endl << endl;
  16.     }
  17. }
  18.  
  19. void toEng(Dictionary a[], string yourword, int n) {
  20.     for (int i = 0; i < n; i++) {
  21.         if (a[i].word_ukr == yourword) {
  22.             cout << "Перевод слова "<< a[i].word_ukr << " на английский: " << a[i].word_eng1 << ", " << a[i].word_eng2 << endl;
  23.         }
  24.     }
  25. }
  26. void toUkr(Dictionary a[], string yourword, int n) {
  27.     for (int i = 0; i < n; i++) {
  28.         if (a[i].word_eng1 == yourword) {
  29.             cout << "Перевод слова " << a[i].word_eng1 << " на украинский: " << a[i].word_ukr << endl;
  30.         }
  31.         else if (a[i].word_eng2 == yourword) {
  32.             cout << "Перевод слова " << a[i].word_eng2 << " на украинский: " << a[i].word_ukr << endl;
  33.         }
  34.     }
  35. }
  36.  
  37. int main()
  38. {
  39.     system("chcp 1251");
  40.     const int n = 2;
  41.     Dictionary a[n] = {
  42.         {"Жопа","Ass","Asshole"},
  43.         {"Член", "Dick", "Cock"}
  44.     };
  45.     showAll(a, n);
  46.     toEng(a,"Жопа",n);
  47.     toUkr(a, "Ass", n);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement