[求助] a=(float) (7/4),a是多少?为什么?
刚在看C语言入门教程~看到这问题~不会....
2007-07-08 22:34
2007-07-08 22:40
a是1.75
我们可以用
a=(float) (7/4);
cout<<a<<endl;
来验证我的说法。
程序代码:
#include <iostream>using namespace std;
struct Node{
float data;
Node(){}
Node(float t){data=1.75;}
}a;ostream& operator <<(ostream& out,const Node& nt)
{
return out<<nt.data;
}int main()
{
a=(float) (7/4);
cout<<a<<endl;
}
[此贴子已经被作者于2007-7-9 0:08:10编辑过]
2007-07-09 00:07
2007-07-09 00:38
2007-07-09 01:14
.........也先谢了~
a=(int) (7.0/4);整体是这样一来的~因为前面有说明~后面没.....
2007-07-09 07:00
2007-07-09 09:00
2007-07-09 09:08
2007-07-09 17:36
2007-07-09 19:58