Advertisement
Tec4Gen

Untitled

Nov 14th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #include<vector>
  2. #include<iostream>
  3. #include<time.h>
  4. #include<iterator>
  5. using namespace std;
  6. void main() {
  7.  
  8. srand(time(NULL));
  9. int k;
  10. int x;
  11. int count=0;
  12. cout << "Введите x: ";
  13. cin >> x;
  14. vector<int> vector_base(10), vector_test;
  15. //Рандомный вектор
  16. for (int i = 0; i < 10; i++) {
  17. vector_base[i] = rand() % 1000;
  18. }
  19. for (int i = 0; i < 10; i++) {
  20. cout << vector_base[i]<<" ";
  21.  
  22. }
  23. cout << endl;
  24. bool flag = true;
  25. for (int i = 0; i < 10; i++) {
  26. count = 0;
  27. k = vector_base[i];
  28. while (k != 0) {
  29. k /=10;
  30. count++;
  31.  
  32. }
  33. if (count == 2) {
  34. vector_base[i] = x;
  35. }
  36.  
  37. }
  38. for (int i = 0; i < 10; i++) {
  39. cout << vector_base[i] << " ";
  40. }
  41. system("pause");
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement