Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- cout << "Type your N: " << endl;
- int n;
- cin >> n;
- int* mas = new int[n];
- int summ_of_mid = 0;
- for (int i = 0; i<=n; i++)
- {
- mas[i] = rand();
- cout << mas[i] << endl;
- summ_of_mid += mas[i];
- }
- cout << "Middle number is: " << (summ_of_mid /= n) << endl;
- int best_n(0);
- for (int i = 0; i<=n; i++)
- {
- float buf_d_b(0);
- float buf_d = ((float)mas[i])/((float)summ_of_mid);
- if (buf_d>buf_d_b)
- {
- buf_d_b = buf_d;
- buf_d = 0;
- best_n = mas[i];
- }
- }
- cout << "Your best number is: " << best_n << endl;
- system("pause");
- delete []mas;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement