#include<iostream>
int Two(int a, const int* c)
{
if(a >= *c)
return a;
else
return *c;
}
int main()
{
std::cout << "請輸入兩個數:" ;
int a, b, *c;
std::cin >> a >> b;
*c = b;
std::cout << "二者中較大的是:" << Two(a, c) << std::endl;
return 0;
}
代碼改成這樣,親測成功:
int a=0, b=0;
int *c = &b;
cout << "請輸入兩個數:" ;
cin >> a >> b;
cout<<"二者中較大的是:"<< Two(a, c) <<endl;