When analyzing data sets, such as data for human heights or for human weights, a
ID: 3845291 • Letter: W
Question
When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data, perhaps by normalizing to values between 0 and 1, or throwing away outliers. For this program, adjust the values by subtracting the smallest value from all the values. If the input is 5 30 5010 70 65 (the first integer is the number of integers that follow), the output is: 20 40 0 60 55 For coding simplicity, follow every output value by a space, even the last one. Your program must define and use a function: int GetMinimumInt(vector listlnts).Explanation / Answer
PROGRAM CODE:
#include <iostream>
#include <vector>
using namespace std;
int GetMinimumInt(vector<int> listInts)
{
int min = listInts[0];
for(int i=1; i<listInts.size(); i++)
{
if(min>listInts[i])
min = listInts[i];
}
return min;
}
int main() {
int N;
vector<int> list;
cout<<"Enter the total number of data: ";
cin>>N;
for(int j=0; j<N; j++)
{
int data;
cout<<" Enter data: ";
cin>>data;
list.push_back(data);
}
int minimum = GetMinimumInt(list);
cout<<endl;
for(int j=0; j<N; j++)
{
list[j] = list[j] - minimum;
cout<<list[j]<<" ";
}
return 0;
}
OUTPUT:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.