• API
• FAQ
• Tools
• Archive
SHARE
TWEET Untitled a guest May 19th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include <iostream>
2. #include <math.h>
3. using namespace std;
4.
5.
6.
7.
8. void Five_dot_one() {
9.     double x, y; //Create variables
10.     cout << "Write x: ";
11.     cin >> x; //Input x
12.     y = abs(x - cos(x)); //Calculate the result
13.     cout << "Y:= " << y << endl << endl; //Result output
14. }
15.
16. void Five_dot_two() {
17.     double x, y; //Create variables
18.     double *temp = &x; //Create variable referenced to X
19.     cout << "Write x: ";
20.     cin >> x;
21.     y = abs(*temp - cos(*temp)); //Calculate the result
22.     cout << "Y:= " << y << endl << endl; //Result output
23. }
24.
25. void Five_dot_three() {
26.     int count = 10, temp, sum = 0; //Create variables
27.     cout << "Enter numbers: ";
28.
29.     int arr; //Create array
30.
31.     for (int i = 0; i < count; i++) {
32.         cin >> temp; //Input variable
33.         arr[i] = temp; //Write down variable to the array
34.     }
35.
36.     temp = arr;
37.     for (int i = 0; i < count; i++) { //Finds minimum positive element
38.         if (temp <= 0)
39.             temp = arr[i];
40.         if (arr[i] > 0 && arr[i] < temp)
41.             temp = arr[i];
42.     }
43.     if (temp > 0)
44.         cout << "Minimum positive element: " << temp << endl;
45.     else
46.         cout << "No positive elements" << endl;
47.
48.     for (int i = 0; i < count; i++) { //Calculate the sum of positive elements
49.         if ((arr[i] > 0) && (arr[i] % 3 == 0))
50.             sum += arr[i];
51.     }
52.     cout << "The sum of positive elements multiple 3: " << sum << endl;
53.
54.     cout << "Non zero elements: " << endl;
55.     for (int i = 0; i < count; i++) { //Calculate the sum of positive elements
56.         if (arr[i] > 0)
57.             cout << arr[i] << endl;
58.     }
59.     cout << endl;
60. }
61.
62. void Five_dot_four() {
63.     int count, temp, sum = 0; //Create variables
64.     cout << "Enter array count: ";
65.     cin >> count;
66.     cout << "Enter numbers: ";
67.
68.     int *arr = new int[count]; //Create array
69.
70.     for (int i = 0; i < count; i++) {
71.         cin >> temp; //Input variable
72.         arr[i] = temp; //Write down variable to the array
73.     }
74.
75.     temp = arr;
76.     for (int i = 0; i < count; i++) { //Finds minimum positive element
77.         if (temp <= 0)
78.             temp = arr[i];
79.         if (arr[i] > 0 && arr[i] < temp)
80.             temp = arr[i];
81.     }
82.     if (temp > 0)
83.         cout << "Minimum positive element: " << temp << endl;
84.     else
85.         cout << "No positive elements" << endl;
86.
87.     for (int i = 0; i < count; i++) { //Calculate the sum of positive elements
88.         if ((arr[i] > 0) && (arr[i] % 3 == 0))
89.             sum += arr[i];
90.     }
91.     cout << "The sum of positive elements multiple 3: " << sum << endl;
92.
93.     cout << "Non zero elements: " << endl;
94.     for (int i = 0; i < count; i++) { //Calculate the sum of positive elements
95.         if (arr[i] > 0)
96.             cout << arr[i] << endl;
97.     }
98.
99.     delete arr;
100. }
101.
102. int main() {
103.     Five_dot_one(); //Call the Five_dot_one function
104.     Five_dot_two(); //Call the Five_dot_two function
105.     Five_dot_three();//Call the Five_dot_three function
106.     Five_dot_four();
107.     system("pause");
108. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top