Advertisement
Dawid_PAr

caly

Aug 6th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. #include <conio.h>
  5. #include <algorithm>
  6. #include <ctime>
  7. #include <cstdlib>
  8.  
  9. using namespace std;
  10.  
  11. void kodPoczt(string dane, string szukana)
  12. {
  13. size_t pozycja = -1;
  14. string maybe;
  15.  
  16. while((pozycja = dane.find(szukana, pozycja+1)) != string::npos)
  17. {
  18. maybe = dane.substr(pozycja-2, 6);
  19. if(maybe.find_first_of("01234456789") == 0)
  20. cout << "Kod pocztowy: " << maybe;
  21. }
  22. }
  23.  
  24. bool algerba(string dzialanie)
  25. {
  26. string szukaj = "+-*/";
  27. string zakaz1 = "()";
  28. string zakaz2 = "*/";
  29. size_t pozycja = -1;
  30. int blad = 0;
  31. while((pozycja = dzialanie.find_first_of(szukaj, pozycja+1)) != string::npos)
  32. {
  33. for(int i = 0; i < 4; i++)
  34. {
  35. if(dzialanie[pozycja] == szukaj[i])
  36. {
  37. if(dzialanie[pozycja+1] == zakaz2[i]) blad+=1;
  38. }
  39. if(dzialanie[pozycja] == zakaz2[i])
  40. {
  41. if((dzialanie[pozycja-1] == zakaz1[i]) && (dzialanie[pozycja+1] == zakaz1[i])) blad+=1;
  42. else if(dzialanie[pozycja-1] == zakaz1[0]) blad+=1;
  43. }
  44. }
  45. }
  46. if(blad >= 1) return false;
  47. else return true;
  48. }
  49. int main()
  50. {
  51. //CWICZENIE
  52. /*
  53. string tekst = "Brzoskwiniowa 50 87-100, Torun Dawid -Parowski";
  54. kodPoczt(tekst, "-");
  55. */
  56.  
  57. //CWICZENIE
  58. /*
  59. cout << "Dzialnie: ";
  60. string dzialan;
  61. cin >> dzialan;
  62. cout << algerba(dzialan);
  63. */
  64.  
  65. //CWICZENIE
  66. /*
  67. ofstream plik1;
  68. plik1.open("plik1.txt");
  69. string tab;
  70. while(true)
  71. {
  72. getline(cin, tab);
  73. if(tab == "") break;
  74. plik1 << tab << endl;
  75. }
  76. plik1.close();
  77. */
  78.  
  79. srand(time(NULL));
  80. int liczba;
  81. int j = 0;
  82. int m;
  83. string znaki= "";
  84. string litera = "P";
  85. for(int i = 0; i < 10; i++)
  86. {
  87. cout << endl;
  88. for (int j = 0; j < 10; j++)
  89. {
  90. liczba = rand()%101+0;
  91. if(liczba+17 == 77)
  92. {
  93. znaki += "@";
  94. cout << "@ ";
  95. }
  96. else
  97. {
  98. if(liczba%2 == 1)
  99. {
  100. znaki += "*";
  101. cout << "* ";
  102. }
  103. else if(liczba%2 == 0)
  104. {
  105. znaki += "#";
  106. cout << "# ";
  107. }
  108. }
  109. }
  110. }
  111.  
  112. liczba = rand()%101+0;
  113. cout << endl << endl << endl;
  114. for(int i = 0; i < 10; i++)
  115. {
  116. cout << endl;
  117. for(int k = 0; k < 10; k++)
  118. {
  119. if(j == liczba)
  120. {
  121. znaki[j] = 'P';
  122. m = j;
  123. }
  124. cout << znaki[j] << " ";
  125. j+=1;
  126. }
  127. }
  128.  
  129. /*
  130. string kierunek;
  131. string buf;
  132. string dot = ".";
  133. while(kierunek != "0")
  134. {
  135. j = 0;
  136. for(int i = 0; i < 10; i++)
  137. {
  138. cin >> kierunek;
  139. cout << endl;
  140. for(int k = 0; k < 10; k++)
  141. {
  142. if(kierunek == "w")
  143. {
  144. znaki[m] = '.';
  145. znaki[m-10] = 'P';
  146. }
  147. cout << znaki[j] << " ";
  148. j+=1;
  149. }
  150. }
  151. }
  152. */
  153.  
  154.  
  155. return 0;
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement