int effectiveness()
{
cout << "Let me check your effectiveness." << endl;
result = scored / throws;
real_result = result * 100;
cout << "It is around " << real_result << " percent." << endl;
return 0;
}
这是我担心的代码,您能告诉我为什么无论我输入什么,real_result总是等于零吗?
检查您的物品类型。如果您的变量结果为int,则无法获得浮点值:
int result;
result = 3/5; //result will egal to zero
result = 3.1/5; //result will egal to zero