Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. /*
  6. --------------------------------------------------------------------
  7. | Observând output-ul programului, realizăm că toate șirurile |
  8. | sunt periodice, unele fiind eventual periodice. |
  9. | Perioada minimă este 2, iar cea maximă este, practic, infinită. |
  10. --------------------------------------------------------------------
  11. */
  12.  
  13. void generate_random_numbers(int number) {
  14. string auxiliary = "";
  15. string number_array = to_string(number) + ", ";
  16. int count = 20;
  17. cout << "\nFor a count of 20, we get the following numbers: " << endl;
  18. while (count) {
  19. if (number < 4)
  20. {
  21. auxiliary = "000" + to_string(number * number);
  22. }
  23. else if (number >= 4 && number < 10)
  24. {
  25. auxiliary = "00" + to_string(number * number);
  26. }
  27. else if (number < 31)
  28. {
  29. auxiliary = "0" + to_string(number * number);
  30. }
  31. else if (number >= 31) {
  32. auxiliary = to_string(number * number);
  33. }
  34. number = stoi(auxiliary.substr(1, 2));
  35. number_array = number_array + to_string(number) + ", ";
  36. count--;
  37. }
  38. cout << number_array << endl;
  39. }
  40.  
  41. int main(int argc, char const **argv) {
  42. for (int i = 10; i < 100; ++i) {
  43. generate_random_numbers(i);
  44. }
  45.  
  46. system("pause");
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement