#include <iostream>
#include <vector>
float min;
float temp;
void computeMin(std::vector<float> nums){
//You could just use the vector size() instead of needing the input.
for (int i = 0; i < nums.size(); ++i){
min = (nums[i] < min) ? nums[i] : min;
}
std::cout << "Incorrect Minimum Value: " << min << std::endl;
}
void computeCorMin(std::vector<float> numArray){
for (int i = 0; i < numArray.size()-1; i++){
temp = numArray[i+1];
min = (numArray[i] < temp) ? numArray[i] : temp;
}
std::cout << "Correct Minimum Value: " << min << std::endl;
}
int main() {
// your code goes here
std::vector<float> arrayTest(3);
arrayTest.push_back(3);
arrayTest.push_back(2);
arrayTest.push_back(1);
arrayTest.push_back(4);
computeMin(arrayTest);
computeCorMin(arrayTest);
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKZmxvYXQgbWluOwpmbG9hdCB0ZW1wOwp2b2lkIGNvbXB1dGVNaW4oc3RkOjp2ZWN0b3I8ZmxvYXQ+IG51bXMpewoJLy9Zb3UgY291bGQganVzdCB1c2UgdGhlIHZlY3RvciBzaXplKCkgaW5zdGVhZCBvZiBuZWVkaW5nIHRoZSBpbnB1dC4KCWZvciAoaW50IGkgPSAwOyBpIDwgbnVtcy5zaXplKCk7ICsraSl7CgkJbWluID0gKG51bXNbaV0gPCBtaW4pID8gbnVtc1tpXSA6IG1pbjsKCX0KCXN0ZDo6Y291dCA8PCAiSW5jb3JyZWN0IE1pbmltdW0gVmFsdWU6ICIgPDwgbWluIDw8IHN0ZDo6ZW5kbDsKfQoKdm9pZCBjb21wdXRlQ29yTWluKHN0ZDo6dmVjdG9yPGZsb2F0PiBudW1BcnJheSl7Cglmb3IgKGludCBpID0gMDsgaSA8IG51bUFycmF5LnNpemUoKS0xOyBpKyspewoJCXRlbXAgPSBudW1BcnJheVtpKzFdOwoJCW1pbiA9IChudW1BcnJheVtpXSA8IHRlbXApID8gbnVtQXJyYXlbaV0gOiB0ZW1wOwoJfQoJc3RkOjpjb3V0IDw8ICJDb3JyZWN0IE1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