Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <map>
- #include <string>
- #include <vector>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- fstream polskie;
- fstream angielskie;
- map<string,string> vpol;
- map<string,string> vang;
- map<string,string>::iterator p;
- map<string,string>::iterator an;
- vector<string> slavic;
- vector<string> germanic;
- vector<string> :: iterator s;
- vector<string> :: iterator g;
- /*typedef map<string,string> StringFloatMap;
- StringFloatMap napol;
- StringFloatMap::iterator pol;*/
- void menu()
- {
- cout << "Menu:" << endl;
- cout << "1) Przeglad slowek" << endl;
- cout << "2) Dodawanie slowek" << endl;
- cout << "3) Usuwananie slowek" << endl;
- cout << "4) Test" << endl;
- cout << "5) Koniec" << endl;
- }
- void jeden()
- {
- /*for (pol = napol.begin(); pol != napol.end(); ++pol) {
- cout << "ANG: \"" << pol->first << "\" "
- << "POL: " << pol->second << endl;*/
- cout << "Oto twoja lista slowek:" << endl;
- polskie.open ("polskie.txt", std::fstream::in);
- angielskie.open ("angielskie.txt", std::fstream::in);
- string a,b;
- while(polskie >> a && angielskie >> b)
- {
- cout << a << " "<< b << endl;
- }
- polskie.close();
- angielskie.close();
- }
- void dwa()
- {
- string a,b;
- cout << "Jakie slowka chcesz dodac?" << endl;
- cout << "Polskie slowo: \n";
- cin >> a;
- cout << "Angielskie slowo: \n";
- cin >> b;
- polskie.open ("polskie.txt", std::fstream::app);
- angielskie.open ("angielskie.txt", std::fstream::app);
- polskie << a << endl;
- angielskie << b << endl;
- cout << "ok \n";
- /*napol["Monday"] = "Poniedzialek";
- napol["Tuesday"]= "Wtorek";
- napol["STFU"]= "Zamknij morde";
- napol["Wednesday"]="Sroda";
- napol["Thursday"]="Czwartek";
- napol["Friday"]="Piatek";*/
- polskie.close();
- angielskie.close();
- }
- void trzy()
- {
- //map<string,string> vpol;
- //map<string,string> vang;
- //map<string,string>::iterator p;
- //map<string,string>::iterator an;
- string a,b;
- polskie.open ("polskie.txt", std::fstream::in | std::fstream::out);
- angielskie.open ("angielskie.txt", std::fstream::in | std::fstream::out);
- while(polskie >> a && angielskie >> b)
- {
- vpol[a] = b;
- //vang[b] = a;
- }
- //an = vang.begin();
- cout << "Ktory element chcesz usunac?:" << endl;
- for (p = vpol.begin(); p != vpol.end(); p++)
- {
- cout << p->first << " " << p->second << endl;
- }
- cout << endl;
- /* polskie.close();
- angielskie.close();
- polskie.open ("polskie.txt");
- angielskie.open ("angielskie.txt"); */
- string u;
- cin >> u;
- cout << endl;
- vpol.erase(u);
- for (p = vpol.begin(); p != vpol.end(); p++)
- {
- cout << p->first << " " << p->second << endl;
- }
- cout << endl;
- /*for (p = vpol.begin(); p != vpol.end(); p++)
- {
- a = p->first;
- b = p->second;
- polskie << a << endl;
- angielskie << b << endl;
- }*/
- polskie.close();
- angielskie.close();
- }
- void pomocniczy()
- {
- polskie.open ("polskie.txt");
- angielskie.open ("angielskie.txt");
- string a,b;
- p = vpol.begin();
- while ( p != vpol.end())
- {
- a = p->first;
- b = p->second;
- polskie << a << endl;
- angielskie << b << endl;
- p++;
- }
- polskie.close();
- angielskie.close();
- }
- void cztery()
- {
- polskie.open ("polskie.txt", std::fstream::in | std::fstream::out);
- angielskie.open ("angielskie.txt", std::fstream::in | std::fstream::out);
- string a, b;
- int iteratorek = 0;
- int dlugosc = 0;
- int wynik = 0;
- while(polskie >> a && angielskie >> b)
- {
- slavic.push_back(a);
- germanic.push_back(b);
- }
- srand(time(NULL));
- for(s = slavic.begin(); s != slavic.end(); s++)
- {
- dlugosc++;
- }
- for(int i = 0; i < 10; i++)
- {
- iteratorek = rand() % dlugosc;
- cout << germanic[iteratorek] << " - ";
- cin >> a;
- if(a == slavic[iteratorek])
- {
- cout << " " << "DOBRZE" << endl;
- wynik ++;
- }
- else
- cout << " " << "ZLE! Poprawna odpowiedz to: " << slavic[iteratorek] << endl;
- }
- cout << endl << "Twoj wynik to: " << wynik << "/10" << endl;
- polskie.close();
- angielskie.close();
- }
- int main()
- {
- menu();
- int x = 1;
- cout << endl;
- //dwa();
- //jeden();
- /*map<string,string>naang;
- naang["Poniedzialek"] = "Monday";
- naang["Wtorek"]= "Tuesday";
- naang["Zamknij morde"]= "STFU";
- naang["Sroda"]="Wednesday";
- naang["Czwartek"]="Thursday";
- naang["Piatek"]="Friday";*/
- while(x != 0)
- {
- switch(getchar())
- {
- case '1':
- jeden();
- break;
- case '2':
- dwa();
- break;
- case '3':
- trzy();
- pomocniczy();
- break;
- case '4':
- cztery();
- break;
- case '5':
- return 0;
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement