该回答引用GPTᴼᴾᴱᴺᴬᴵ
#include <iostream>
#include <math.h>
using namespace std;
int max(int a, int b) {
int c;
if (a > b) {
c = a;
} else {
c = b;
}
return c;
}
int main() {
int a, b, c;
cout << "a=";
cin >> a;
cout << "b=";
cin >> b;
c = max(a, b);
cout << "c=" << c << endl;
return 0;
}
第7行删掉,这时候a和b还没有输入呢,你判断啥大小
然后max函数太罗嗦,只需要:
int max(int a,int b)
{
if(a>b)
return a;
return b;
}
就可以了