Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- using namespace std;
- void show_arr(int size, int arr[]) {
- for (int k = 0; k < size; k++) {
- cout << arr[k] << " ";
- }
- cout << endl;
- }
- void show_arr(int size, double arr[]) {
- for (int k = 0; k < size; k++) {
- cout << arr[k] << " ";
- }
- cout << endl;
- }
- int gen_rand(int a, int b) {
- return rand() % (b + 1 - a) + a;
- }
- void gen_randarr(int size, int arr[], int a, int b) {
- for (int k = 0; k < size; k++) {
- arr[k] = gen_rand(a, b);
- }
- }
- /// <summary>
- /// Calc area for trapetc
- /// </summary>
- /// <param name="a">side of trapec</param>
- /// <param name="b">side if trapec</param>
- /// <param name="h">height of trapec</param>
- /// <returns>Area of trapec</returns>
- double calc_area(double a, double b, double h) {
- return 0.5 * (a + b) * h;
- }
- bool is_prime(int x) {
- if (x <= 0)
- return false;
- for (int v = 2; v <= sqrt(x); ++v) {
- if (x % v == 0)
- return false;
- }
- return true;
- }
- void show_minmax(int size, int arr[]) {
- int max = arr[0];
- int min = arr[0];
- int idmax = 0;
- int idmin = 0;
- for (int k = 1; k < size; k++) {
- if (max < arr[k]) {
- max = arr[k];
- idmax = k;
- }
- if (min > arr[k]) {
- min = arr[k];
- idmin = k;
- }
- }
- cout << "max in " << idmax + 1 << " equal " << max << endl;
- cout << "min in " << idmin + 1 << " equal " << min << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement