Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication4.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <cmath>
- using namespace std;
- void inputArray(int* array, int n)
- {
- cout << "Enter " << n << " elements:\n";
- for (int i = 0; i < n; i++)
- {
- cin >> array[i];
- }
- }
- void printArray(int* array, int n)
- {
- cout << "The sorted array is: ";
- for (int i = 0; i < n; i++)
- {
- cout << array[i] << " ";
- }
- cout << endl;
- }
- void square(int* array, int n)
- {
- for (int i = 0; i < n; i++)
- {
- array[i] = pow(array[i], 2);
- }
- }
- int minValue(int* array, int n)
- {
- int min = array[0];
- for (int i = 0; i < n; ++i)
- {
- if (array[i] < min)
- {
- min = array[i];
- }
- }
- return min;
- }
- int main()
- {
- int array_1[6], array_2[5];
- inputArray(array_1, 6);
- inputArray(array_2, 5);
- square(array_1, 6);
- square(array_2, 5);
- printArray(array_1, 6);
- printArray(array_2, 5);
- cout << "Minimal is: " << minValue(array_1, 6) << " and " << minValue(array_2, 5) << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement