51 lines
1.1 KiB
C++

#include <iostream>
#include <iomanip>
#include <vector>
using namespace std;
int main() {
/* Type your code here. */
//Take in values
//Divide all values by largest value
//input begins with INT indicating number of floats
//Output each float with two digits after decimal
//cout << fixed << setprecision(2) once before other cout statements
//EX
//input: 5 30.0 50.0 10.0 100.0 65.0
//Output: 0.30 0.50 0.10 1.00 0.65
//For simplicity, follow every output value by a space, including last one
vector<float> userFloats;
int unsigned i;
int numFloats;
float fltLargest;
cin >> numFloats;
userFloats.resize(numFloats);
//Get numbers
for (i=0; i<userFloats.size();i++){
cin >> userFloats.at(i);
}
//Find max
fltLargest = userFloats.at(0);
for (i=0; i<userFloats.size();i++){
if (userFloats.at(i) > fltLargest){
fltLargest = userFloats.at(i);
}
}
//divde values by largest
for (i=0; i<userFloats.size(); i++){
userFloats.at(i) = userFloats.at(i)/fltLargest;
}
cout << fixed << setprecision(2);
for (i=0; i<userFloats.size();i++){
cout << userFloats.at(i) << " ";
}
cout << endl;
return 0;
}