PanZefir

lowest positive

May 15th, 2021
488
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. // zwraca najmniejsza wartosc i przez arguiment pozycje pierwszego wystapienia
  7. int findLowestPositiveNumber(const vector<float> source, int &position)
  8. {
  9.     int i, count = source.size();
  10.     float lowestPositive = FLT_MAX;
  11.    
  12.     for (i = 0; i < count; i++)
  13.     {
  14.         float numberToCheck = source[i];
  15.         if (numberToCheck > 0 && numberToCheck < lowestPositive) {
  16.             lowestPositive = numberToCheck;
  17.             position = i;
  18.         }
  19.     }
  20.  
  21.     return lowestPositive;
  22. }
  23.  
  24. int main()
  25. {
  26.     std::cout << "Hello World!\n";
  27. }
RAW Paste Data