真的有看没有懂,先随便乱凑
明天再来看看
复制程式
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
vector <double>v;
vector <double>::iterator it;
double sum=0;
int nn;
void sub1(){
int n;
double t;
ifstream fi("order.txt");
fi>>n;
nn=n;
while(n--){
fi>>t;
v.push_back(t);
}
}
void sub2(){
int s=0;
sort(v.begin(),v.end());
for(it=v.begin();it!=v.end();it++,s++)
if(s>=nn-2){
sum+=((*it)*0.9);
}else
sum+=*it;
}
void sub3(){
int s=1;
for(it=v.begin();it!=v.end();it++,s++)
cout<<s<<" "<<*it<<" "<<(*it)*32.252<<endl;
cout<<sum*32.252<<endl;
}
int main(){
sub1();
sub2();
sub3();
getchar();
return 0;
}