Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- int genRand(int minVal, int maxVal)
- {
- return (rand() % (maxVal - minVal) + 1);
- }
- int max(int a, int b)
- {
- return (a > b ? a : b);
- }
- //maxPrint(x, y, true);
- int maxPrint(int a, int b, bool print)
- {
- //int a{x};
- //int b{y};
- //bool print{true};
- int maxVal{ a > b ? a : b };
- if (print)
- {
- std::cout << "maxPrint -> max = " << maxVal << '\n';
- }
- return maxVal;
- }
- int count()
- {
- const int maxVal{ (rand() % 11) + 1 };
- //std::cout << "count() -> maxVal = " << maxVal << '\n';
- int sum{ 0 };
- for (int i{ 0 }; i < maxVal; ++i)
- {
- sum += i;
- //std::cout << "Sum = " << sum << ' ';
- }
- //std::cout << '\n';
- //std::cout << "Sum of numbers from 0 to some random [0..10] is " << sum << '\n';
- return sum;
- }
- void sayHello()
- {
- std::cout << "\n#####\n";
- std::cout << "Hello, I'm sayHello function!\n";
- if (rand() % 2)
- {
- return;
- }
- std::cout << "I'm useless, but nice function! :()\n";
- std::cout << "\n#####\n";
- return;
- }
- void testFun()
- {
- std::cout << "i'm testFun\n";
- };
- void sayGoodbye()
- {
- testFun();
- std::cout << "Simply bye!\n";
- }
- int main()
- {
- const int arrSize{ 10 };
- int arr[arrSize]{};
- int arr1[arrSize]{};
- int x{};
- int y{};
- const int answer{ 42 };
- int val{};
- std::cout << "Start of the programm\n";
- srand(time(0));
- std::cout << "Enter A value\n";
- std::cin >> x;
- std::cout << "Enter B value\n";
- std::cin >> y;
- //std::cout << "Max = " << max(a,b) << '\n';
- maxPrint(x, y, true);
- std::cout << "Complete answer is: " << max(answer, max(x, y)) << '\n';
- //for (int i{ 0 }; i < arrSize; ++i) { std::cout << arr[i] << ' '; } std::cout << '\n';
- //for (int i{ 0 }; i < arrSize; ++i) { std::cout << arr1[i] << ' '; } std::cout << '\n';
- //for (int i{ 0 }; i < arrSize; ++i)
- //{
- // arr[i] = genRand(10,30);
- // arr1[i] = genRand(40, 50);
- //}
- //for (int i{ 0 }; i < arrSize; ++i) { std::cout << arr[i] << ' '; } std::cout << '\n';
- //for (int i{ 0 }; i < arrSize; ++i) { std::cout << arr1[i] << ' '; } std::cout << '\n';
- return 0;
- std::cout << "Sum of numbers from 0 to some random [0..10] is " << count() << '\n';
- //count();
- //std::cout << "Val = " << (val = rand() % count()) << '\n';
- ////sayHello();
- //std::cout << "some actions in programm...\n";
- //sayHello();
- //std::cout << "Another actions some actions in programm...\n";
- //sayHello();
- //std::cout << "Some MORE actions in programm...\n";
- //sayGoodbye();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement