65 lines
1.6 KiB
C++
65 lines
1.6 KiB
C++
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
|
|
// ifstream in("test.in");
|
|
// ofstream out("test.out");
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
string inName = "test.in";
|
|
string outName = "test.out";
|
|
|
|
if (argc > 1) {
|
|
inName = argv[1];
|
|
cout << "Using \"" << inName << "\" for test name" << endl;
|
|
} else {
|
|
cout << "Warning: no in name provided, defaulting to test.in" << endl;
|
|
}
|
|
|
|
if (argc > 2) {
|
|
outName = argv[2];
|
|
cout << "Using \"" << outName << "\" for out name" << endl;
|
|
} else {
|
|
cout << "Warning: no out name proviced, defaulting to test.out" << endl;
|
|
}
|
|
|
|
ifstream in(inName);
|
|
ofstream out(outName);
|
|
|
|
int n;
|
|
in >> n;
|
|
|
|
string tmpLName;
|
|
string tmpFName;
|
|
int tmpConsumption = 0;
|
|
int totalConsumption = 0;
|
|
int maxConsumption = -1;
|
|
string biggestConsumer;
|
|
int minConsumption = 4001;
|
|
string smallestConsumer;
|
|
|
|
for (int i = 0; i < n; i++) {
|
|
in >> tmpLName;
|
|
in >> tmpFName;
|
|
in >> tmpConsumption;
|
|
|
|
totalConsumption += tmpConsumption;
|
|
if (tmpConsumption > maxConsumption) {
|
|
maxConsumption = tmpConsumption;
|
|
biggestConsumer = tmpLName + " " + tmpFName;
|
|
}
|
|
if (tmpConsumption < minConsumption) {
|
|
minConsumption = tmpConsumption;
|
|
smallestConsumer = tmpLName + " " + tmpFName;
|
|
}
|
|
|
|
}
|
|
out << fixed << setprecision(2) << setw(10) << ((float)(totalConsumption) / (float)n) << endl;
|
|
// out << biggestConsumer << " " << maxConsumption << endl;
|
|
// out << smallestConsumer << " " << minConsumption << endl;
|
|
|
|
|
|
return 0;
|
|
} |