Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- /*
- --------------------------------------------------------------------
- | Observând output-ul programului, realizăm că toate șirurile |
- | sunt periodice, unele fiind eventual periodice. |
- | Perioada minimă este 2, iar cea maximă este, practic, infinită. |
- --------------------------------------------------------------------
- */
- void generate_random_numbers(int number) {
- string auxiliary = "";
- string number_array = to_string(number) + ", ";
- int count = 20;
- cout << "\nFor a count of 20, we get the following numbers: " << endl;
- while (count) {
- if (number < 4)
- {
- auxiliary = "000" + to_string(number * number);
- }
- else if (number >= 4 && number < 10)
- {
- auxiliary = "00" + to_string(number * number);
- }
- else if (number < 31)
- {
- auxiliary = "0" + to_string(number * number);
- }
- else if (number >= 31) {
- auxiliary = to_string(number * number);
- }
- number = stoi(auxiliary.substr(1, 2));
- number_array = number_array + to_string(number) + ", ";
- count--;
- }
- cout << number_array << endl;
- }
- int main(int argc, char const **argv) {
- for (int i = 10; i < 100; ++i) {
- generate_random_numbers(i);
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement