Skip to content

Instantly share code, notes, and snippets.

@CodeMaks360
Created September 20, 2020 13:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeMaks360/61525493cfcbef05ef4f191a3deadc07 to your computer and use it in GitHub Desktop.
Save CodeMaks360/61525493cfcbef05ef4f191a3deadc07 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <windows.h>
#include <ctime>
#include <conio.h>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
// 0 - obce na PL; 1 - PL na obce
bool lang = 0;
/* //komunikat
cout << "UWAGA! JESLI PODCZAS ZAPYTANIA '(Y/N)' NIE NACISNIESZ ZADNEJ Z DWOCH WYMIENIONYCH LITER \nPROGRAM PRZESTANIE DZIALAC POPRAWNIE!" << endl;
Sleep(8000);
cout << "Pamietaj aby dodawac slowa i ich tlumaczenia w tej samej kolejnosci!" << endl;
Sleep(5000);
cout << "Milej nauki!" << endl;
Sleep(3000);
system("cls");
*/
//obce slowa
int j;
cout << "Ile slowek chcesz dodac?" << endl;
do
{
cin >> j;
}while(j <= 0);
cout << "Podaj slowa w jezyku obcym:" << endl;
string wordsENG[j];
for(int i = 0; i<j; i++)
{
cout << "Podaj " << i+1 << " slowo: ";
getline (cin, wordsENG[i]);
for_each(wordsENG[i].begin(), wordsENG[i].end(), [](char & c) {
c = ::tolower(c);
});
}
//tlumaczenie
cout << "Teraz podaj ich tlumaczenie:" << endl;
string wordsPL[j];
for(int i = 0; i<j; i++)
{
getline (cin, wordsPL[i]);
for_each(wordsPL[i].begin(), wordsPL[i].end(), [](char & c) {
c = ::tolower(c);
});
}
//wejscie do glownej petli
system("cls");
char klik;
klik = 121;
//glowna petla
for(;;)
{
switch(klik)
{
case 121:
{
switch(lang)
{
case 0:
{
srand(time(NULL));
int los = rand() % j;
cout << wordsENG[los] << endl;
cout << "Podaj tlumaczenie na polski: ";
string PL;
cin >> PL;
for_each(PL.begin(), PL.end(), [](char & c) {
c = ::tolower(c);
});
if(PL == wordsPL[los])
{
cout << "Brawo!" << endl;
cout << "Zmienic jezyk? (C)" << endl;
cout << "Kontynuowac? (Y/N)" << endl;
klik = getch();
system("cls");
}
else
{
cout << "Niepoprawnie! Jest to " << wordsPL[los] << endl;
cout << "Zmienic jezyk? (C)" << endl;
cout << "Kontynuowac? (Y/N)" << endl;
klik = getch();
system("cls");
}
}break;
case 1:
{
srand(time(NULL));
int los = rand() % j;
cout << wordsPL[los] << endl;
cout << "Podaj tlumaczenie na angielski: ";
string ENG;
cin >> ENG;
for_each(ENG.begin(), ENG.end(), [](char & c) {
c = ::tolower(c);
});
if(ENG == wordsENG[los])
{
cout << "Brawo!" << endl;
cout << "Zmienic jezyk? (C)" << endl;
cout << "Kontynuowac? (Y/N)" << endl;
klik = getch();
system("cls");
}
else
{
cout << "Niepoprawnie! Jest to " << wordsENG[los] << endl;
cout << "Zmienic jezyk? (C)" << endl;
cout << "Kontynuowac? (Y/N)" << endl;
klik = getch();
system("cls");
}
}break;
default:
{
}break;
}break;
case 99:
{
lang = !(lang);
}break;
case 110:
{
return 0;
}break;
default:
{
}break;
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment