Advertisement
homeworkhelp111

normalize

Feb 5th, 2022
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int GetMaxInt(vector<int> listInts) {
  7.     int max = listInts[0];
  8.  
  9.     for (int i = 0; i < listInts.size(); i++) {
  10.         if (listInts[i] > max) {
  11.             max = listInts[i];
  12.         }
  13.     }
  14.  
  15.     return max;
  16. }
  17. int main() {
  18.     int size,i,max;
  19.     cin >> size;
  20.  
  21.     vector<int> userValues(size);
  22.     for (i = 0; i < userValues.size(); i++) {
  23.         cin >> userValues[i];
  24.     }
  25.     max = GetMaxInt(userValues);
  26.  
  27.     for (i = 0; i < userValues.size(); i++) {
  28.         cout << abs(userValues[i] - max) << " ";
  29.     }
  30.     cout << endl;
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement