int main()
{
float a = 1.0;
float b = 0.0;
float c = a+ (b==0)?1:5;
std::cout << ":%f " << c << "!\n";
return 0;
}
输出不对:输出1.0
修改:
#include <iostream>
using namespace std;
int main()
{
float a = 1.0;
float b = 0;
float c = a+ (b?1:5);
std::cout << ":%f " << c << "!\n";
return 0;
}
就对了,
优先级问题,