Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main()
- {
- int n,m;
- double ats= 0;
- double ats2 = 0;
- int Prek[100];
- int temp;
- ifstream fd("akcija.in");
- ofstream fr("akcija.out");
- fd >> m >> n;
- for (int i = 1; i <= n; i++){
- fd >> Prek[i];
- //cout << Prek[i] << endl;
- }
- cout << "-----" << endl;
- for (int i = 1; i <= n ; i++) {
- for (int j = 1; j <= n ; j++) {
- if (Prek[j] > Prek[j+1] && Prek[j+1] > 0){
- temp = Prek[j];
- Prek[j] = Prek[j+1];
- Prek[j+1] = temp;
- }
- }
- }
- for (int i = 1; i <= m ; i++) {
- ats = ats + Prek[i];
- }
- for (int i = n; i > n-m ; i--) {
- ats2 = ats2 + Prek[i];
- }
- ats2 = ats2 / 100;
- ats2 = Prek[n-m+1] / ats2;
- ats = ats / 100;
- ats = Prek[1] / ats;
- cout << ats2<< endl;
- if (ats2 > ats) {
- fr << setprecision(8) << ats2;}
- else {fr << setprecision(8) << ats;}
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement