Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include "queue.h"
  3. #include <ctime>
  4. using namespace std;
  5.  
  6. const int n = 20; //кол-во элементов в очереди
  7.  
  8. int main() {
  9. queue<char> q1, q2;
  10.  
  11. srand(time(0));
  12.  
  13. for (int i = 0; i < n; ++i) {
  14. q1.enqueue(rand() % 26 + 90); //вводим случайные символы
  15. }
  16.  
  17. cout << "Och1: ";
  18. q1.Print();
  19. cout << endl;
  20.  
  21. int kol = 0; //переменная для нахождения колва
  22. while (!q1.isEmpty()) {
  23. int x = q1.dequeue();
  24. if (x >= 97 && x <=122) {
  25. q2.enqueue(x);
  26. kol++; //увеличиваем значение суммы, если элемент кратен 3
  27. }
  28. }
  29. cout << endl << "Och2: ";
  30. q2.Print();
  31. cout << " - simvoli.";
  32. cout << endl << endl
  33. << "Kol = " << kol << endl;
  34. cout << endl;
  35. system("pause");
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement