c++ if-else语句

2024-12-13 12:16:07
推荐回答(2个)
回答1:

因为你的int main(),所以你在else{}里也应该有return 语句。否则不能通过编译的。

回答2:

#include
using namespace std;
int main()
{
int n,savings,expenses;
cout<<"Enter two numbers:\n";
cin>>savings>>expenses;
n=savings-expenses;
if(n>0)
{
cout<<"Solvent"<<"\n";
cout<return 0;
}else
{
cout<<"Bankrupt";
}
}