Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- //Створити масив структур, який містить відомості щодо словника. Кожна структура містить поля: слово і його кілька перекладів.
- //Реалізувати виведення всього словника, переклад з української на англійську, з англійської на українську.
- struct Dictionary {
- string word_ukr;
- string word_eng1;
- string word_eng2;
- };
- void showAll(Dictionary[], int);
- void showAll(Dictionary a[], int n) {
- for (int i = 0; i < n; i++) {
- cout << "Слово "<< i+1 << ":" << endl <<a[i].word_ukr << endl << a[i].word_eng1 << endl << a[i].word_eng2 << endl << endl;
- }
- }
- void toEng(Dictionary a[], string yourword, int n) {
- for (int i = 0; i < n; i++) {
- if (a[i].word_ukr == yourword) {
- cout << "Перевод слова "<< a[i].word_ukr << " на английский: " << a[i].word_eng1 << ", " << a[i].word_eng2 << endl;
- }
- }
- }
- void toUkr(Dictionary a[], string yourword, int n) {
- for (int i = 0; i < n; i++) {
- if (a[i].word_eng1 == yourword) {
- cout << "Перевод слова " << a[i].word_eng1 << " на украинский: " << a[i].word_ukr << endl;
- }
- else if (a[i].word_eng2 == yourword) {
- cout << "Перевод слова " << a[i].word_eng2 << " на украинский: " << a[i].word_ukr << endl;
- }
- }
- }
- int main()
- {
- system("chcp 1251");
- const int n = 2;
- Dictionary a[n] = {
- {"Жопа","Ass","Asshole"},
- {"Член", "Dick", "Cock"}
- };
- showAll(a, n);
- toEng(a,"Жопа",n);
- toUkr(a, "Ass", n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement