Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- void Five_dot_one() {
- double x, y; //Create variables
- cout << "Write x: ";
- cin >> x; //Input x
- y = abs(x - cos(x)); //Calculate the result
- cout << "Y:= " << y << endl << endl; //Result output
- }
- void Five_dot_two() {
- double x, y; //Create variables
- double *temp = &x; //Create variable referenced to X
- cout << "Write x: ";
- cin >> x;
- y = abs(*temp - cos(*temp)); //Calculate the result
- cout << "Y:= " << y << endl << endl; //Result output
- }
- void Five_dot_three() {
- int count = 10, temp, sum = 0; //Create variables
- cout << "Enter numbers: ";
- int arr[10]; //Create array
- for (int i = 0; i < count; i++) {
- cin >> temp; //Input variable
- arr[i] = temp; //Write down variable to the array
- }
- temp = arr[0];
- for (int i = 0; i < count; i++) { //Finds minimum positive element
- if (temp <= 0)
- temp = arr[i];
- if (arr[i] > 0 && arr[i] < temp)
- temp = arr[i];
- }
- if (temp > 0)
- cout << "Minimum positive element: " << temp << endl;
- else
- cout << "No positive elements" << endl;
- for (int i = 0; i < count; i++) { //Calculate the sum of positive elements
- if ((arr[i] > 0) && (arr[i] % 3 == 0))
- sum += arr[i];
- }
- cout << "The sum of positive elements multiple 3: " << sum << endl;
- cout << "Non zero elements: " << endl;
- for (int i = 0; i < count; i++) { //Calculate the sum of positive elements
- if (arr[i] > 0)
- cout << arr[i] << endl;
- }
- cout << endl;
- }
- void Five_dot_four() {
- int count, temp, sum = 0; //Create variables
- cout << "Enter array count: ";
- cin >> count;
- cout << "Enter numbers: ";
- int *arr = new int[count]; //Create array
- for (int i = 0; i < count; i++) {
- cin >> temp; //Input variable
- arr[i] = temp; //Write down variable to the array
- }
- temp = arr[0];
- for (int i = 0; i < count; i++) { //Finds minimum positive element
- if (temp <= 0)
- temp = arr[i];
- if (arr[i] > 0 && arr[i] < temp)
- temp = arr[i];
- }
- if (temp > 0)
- cout << "Minimum positive element: " << temp << endl;
- else
- cout << "No positive elements" << endl;
- for (int i = 0; i < count; i++) { //Calculate the sum of positive elements
- if ((arr[i] > 0) && (arr[i] % 3 == 0))
- sum += arr[i];
- }
- cout << "The sum of positive elements multiple 3: " << sum << endl;
- cout << "Non zero elements: " << endl;
- for (int i = 0; i < count; i++) { //Calculate the sum of positive elements
- if (arr[i] > 0)
- cout << arr[i] << endl;
- }
- delete arr;
- }
- int main() {
- Five_dot_one(); //Call the Five_dot_one function
- Five_dot_two(); //Call the Five_dot_two function
- Five_dot_three();//Call the Five_dot_three function
- Five_dot_four();
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement