Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- void first() {
- double arr[10]; //Create float array
- cout << "Write down 10 numbers for array: " << endl;
- for (int i = 0; i < 10; i++) //Input numbers to the array
- {
- cin >> arr[i];
- }
- double temp = arr[0];
- for (int i = 0; i < 10; i++) //Find maximum element
- {
- if (temp < arr[i])
- temp = arr[i];
- }
- cout << "Maximum element: " << temp << endl;
- double sum = 0;
- for (int i = 0; i < 10; i++) //Calculate sum of all negative numbers
- {
- if (arr[i] < 0)
- sum += arr[i];
- }
- cout << "The arithmetic mean of the negative elements: " << sum << endl;
- cout << "Reverse array: " << endl;
- for (int i = 9; i >= 0; i--) //Output the reverse array
- {
- cout << arr[i] << ' ';
- }
- }
- void second() {
- int arr[5][6]; //Create two-dimensional array
- int arr2[6]; //Create one-dimensional array
- for (int i = 0; i < 5; i++) //Input numbers for two-dimensional array
- {
- cout << "Write down 6 numbers for " << i + 1 << " line:" << endl;
- for (int j = 0; j < 6; j++)
- {
- cin >> arr[i][j];
- }
- }
- int temp;
- for (int i = 0; i < 6; i++) //Find maximum element by modul and fill new array
- {
- temp = arr[0][i];
- for (int j = 0; j < 5; j++)
- {
- //cout << arr[j][i];
- if (abs(arr[j][i]) > temp)
- temp = abs(arr[j][i]);
- }
- cout << i + 1 << " column: " << temp << endl;
- arr2[i] = temp;
- }
- }
- int main() {
- first(); //Call the function
- second(); //Call the function
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement