Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- bool startNuclearWar{ false };
- // 10 20
- int genRand(int minVal, int maxVal)
- {
- return (rand() % (maxVal - minVal) + minVal);
- }
- int max(int a, int b)
- {
- return (a > b ? a : b);
- }
- //maxPrint(x, y, true);
- // maxPrint(answer, (maxPrint(x, y, false) + genRand(10,20))+2, true);
- int maxPrint(int a, int b, bool print)
- {
- //int a{x};
- //int b{};
- //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()
- {
- startNuclearWar = true;
- 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";
- }
- void swapVal(int num1, int num2);
- const int correctAnswer{ 42 };
- int arrG[10]{ 23,56,788,3 };
- void checkState()
- {
- /// ????
- ///
- ///
- startNuclearWar = false;
- }
- int counter()
- {
- static int cnt{ 0 };
- return ++cnt;
- }
- void printArr(int arrPrn[], int arrSize)
- {
- for (int i{ 0 }; i < arrSize; ++i)
- {
- arrPrn[i] = genRand(10, 30);
- std::cout << arrPrn[i] << ' ';
- }
- std::cout << '\n';
- }
- int main()
- {
- const int arrSize{ 10 };
- const int arrSize1{ 5 };
- int arr[arrSize]{};
- int arr1[arrSize1]{};
- int x{};
- int y{};
- //for (int i{ 0 }; i < 5; ++i)
- //{
- // std::cout << counter() << ' ';
- //}
- //std::cout << '\n';
- /*int k{ 10 };
- int j{ 20 };
- std::cout << "k = " << k << " j = " << j << '\n';
- swapVal(k, j);
- std::cout << "k = " << k << " j = " << j << '\n';
- return 0;*/
- 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';
- //std::cout << "Max from X and Y is: " << maxPrint(x, y, false) << '\n';
- ////std::cout << "Complete answer is: " << max(answer, max(x, y)) << '\n';
- //maxPrint(answer, (maxPrint(x, y, false) + genRand(10,20))+2, true);
- printArr(arr, arrSize);
- printArr(arr1, arrSize1);
- //for (int i{ 0 }; i < arrSize; ++i)
- //{
- // arr[i] = genRand(10,30);
- // if (i < arrSize1)
- // {
- // arr1[i] = genRand(40, 50);
- // }
- //}
- //printArr(arr, arrSize);
- //printArr(arr1, arrSize1);
- for (int i{ 0 }; i < arrSize; ++i) { std::cout << arr[i] << ' '; } std::cout << '\n';
- for (int i{ 0 }; i < arrSize1; ++i) { std::cout << arr1[i] << ' '; } std::cout << '\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';
- 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;
- }
- void swapVal(int num1, int num2)
- {
- std::cout << "num1 = " << num1 << " num2 = " << num2 << '\n';
- int tmp{ num1 };
- num1 = num2;
- num2 = tmp;
- std::cout << "num1 = " << num1 << " num2 = " << num2 << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment