#include <stdio.h>
#include <iostream>
using namespace std;
int getMaior(int a, int b);
int main(void) {
int cont, maior = 0;
do {
cout << "digite um valor: ";
cin >> cont;
//Se o valor entrado for maior que o ultimo passa ele a ser o maior
maior = getMaior(cont, maior);
}while (cont != -1);
cout << "o maior numero e: " << maior;
return 0;
}
int getMaior(int a, int b){
if (a>b) return a;
return b;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxpb3N0cmVhbT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IGdldE1haW9yKGludCBhLCBpbnQgYik7CmludCBtYWluKHZvaWQpIHsKICAgIGludCBjb250LCBtYWlvciA9IDA7CiAgICBkbyB7CiAgICAgICAgY291dCA8PCAiZGlnaXRlIHVtIHZhbG9yOiAiOwogICAgICAgIGNpbiA+PiBjb250OwogICAgICAgIC8vU2UgbyB2YWxvciBlbnRyYWRvIGZvciBtYWlvciBxdWUgbyB1bHRpbW8gcGFzc2EgZWxlIGEgc2VyIG8gbWFpb3IKICAgICAgICBtYWlvciA9IGdldE1haW9yKGNvbnQsIG1haW9yKTsKICAgIH13aGlsZSAoY29udCAhPSAtMSk7CiAgICBjb3V0IDw8ICJvIG1haW9yIG51bWVybyBlOiAiIDw8IG1haW9yOwogICAgcmV0dXJuIDA7Cn0KCmludCBnZXRNYWlvcihpbnQgYSwgaW50IGIpewogICAgaWYgKGE+YikgcmV0dXJuIGE7CiAgICByZXR1cm4gYjsKfQ==