Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <map>
  4. #include <string>
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. std::fstream polskie;
  10. std::fstream angielskie;
  11.  
  12. /*typedef map<string,string> StringFloatMap;
  13. StringFloatMap napol;
  14. StringFloatMap::iterator pol;*/
  15.  
  16. void menu()
  17. {
  18. cout << "Menu:" << endl;
  19. cout << "1) Przeglad slowek" << endl;
  20. cout << "2) Dodawanie slowek" << endl;
  21. cout << "3) Usuwananie slowek" << endl;
  22. cout << "4) Test" << endl;
  23. cout << "5) Koniec" << endl;
  24. }
  25. void jeden()
  26. {
  27. /*for (pol = napol.begin(); pol != napol.end(); ++pol) {
  28. cout << "ANG: \"" << pol->first << "\" "
  29. << "POL: " << pol->second << endl;*/
  30. cout << "Oto twoja lista slowek:" << endl;
  31. polskie.open ("polskie.txt", std::fstream::in);
  32. angielskie.open ("angielskie.txt", std::fstream::in);
  33. string a,b;
  34. while(polskie >> a && angielskie >> b)
  35. {
  36. cout << a << " "<< b << endl;
  37. }
  38. polskie.close();
  39. angielskie.close();
  40. }
  41.  
  42. void dwa()
  43. {
  44. string a,b;
  45. cout << "Jakie slowka chcesz dodac?" << endl;
  46. cout << "Polskie slowo: \n";
  47. cin >> a;
  48. cout << "Angielskie slowo: \n";
  49. cin >> b;
  50. polskie.open ("polskie.txt", std::fstream::app);
  51. angielskie.open ("angielskie.txt", std::fstream::app);
  52. polskie << a << endl;
  53. angielskie << b << endl;
  54. cout << "ok \n";
  55. /*napol["Monday"] = "Poniedzialek";
  56. napol["Tuesday"]= "Wtorek";
  57. napol["STFU"]= "Zamknij morde";
  58. napol["Wednesday"]="Sroda";
  59. napol["Thursday"]="Czwartek";
  60. napol["Friday"]="Piatek";*/
  61. polskie.close();
  62. angielskie.close();
  63.  
  64. }
  65. void trzy()
  66. {
  67. vector<string> vpol;
  68. vector<string> vang;
  69. vector<string>::iterator p;
  70. vector<string>::iterator an;
  71. string a,b;
  72. int i = 1;
  73. polskie.open ("polskie.txt", std::fstream::app);
  74. angielskie.open ("angielskie.txt", std::fstream::app);
  75. while(polskie >> a && angielskie >> b)
  76. {
  77. vpol.push_back(a);
  78. vang.push_back(b);
  79. }
  80. an = vang.begin();
  81. cout << "Ktory element chcesz usunac?:";
  82. for (p = vpol.begin(); p != vpol.end(); p+= a.size())
  83. {
  84. a = *p;
  85. b = *an;
  86. cout << i << ". " << a << " " << b << endl;
  87. an += b.size();
  88. i++;
  89.  
  90. }
  91. polskie.close();
  92. angielskie.close();
  93. }
  94.  
  95. int main()
  96. {
  97. menu();
  98. int x = 1;
  99. cout << endl;
  100.  
  101. //dwa();
  102. //jeden();
  103. /*map<string,string>naang;
  104. naang["Poniedzialek"] = "Monday";
  105. naang["Wtorek"]= "Tuesday";
  106. naang["Zamknij morde"]= "STFU";
  107. naang["Sroda"]="Wednesday";
  108. naang["Czwartek"]="Thursday";
  109. naang["Piatek"]="Friday";*/
  110. while(x != 0)
  111. {
  112. switch(getchar())
  113. {
  114. case '1':
  115. jeden();
  116. break;
  117. case '2':
  118. dwa();
  119. break;
  120. case '3':
  121. trzy();
  122. break;
  123. case '4':
  124.  
  125. break;
  126. case '5':
  127. return 0;
  128. break;
  129. }
  130. }
  131. return 0;
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement