|
查看: 1037|回复: 3
|
要如何用C++做dice???
[复制链接]
|
|
|
我是C++的初学者,想请问下...............
我用的是borland C++, 要如何作出像dice酱,能够randomly给我一个号码??
[ 本帖最后由 Wongkokchoy 于 7-9-2008 11:17 AM 编辑 ] |
|
|
|
|
|
|
|
|
|
|
发表于 6-9-2008 07:09 PM
|
显示全部楼层
There is a restriction in C language while using the modulus operator. it can operator only on integers and cannot operate on floats or double. If anyone tries to use the modulus operator on floats then the compiler would display error message as ‘Illegal use of Floating Point’.
Let us see this with an example:
main () { float x=7,y=5; int z; z = x % y; printf( %d”, z)’; }
This above program would give error as ‘Illegal use of Floating Point’.
基本上是说 % (modulus) 必须用整数 (int).
这样行吗?
z = ((int)paid - (int)price)%(50); |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 6-9-2008 07:53 PM
|
显示全部楼层
------------------------------已修改-------------------------------
[ 本帖最后由 Wongkokchoy 于 6-9-2008 08:49 PM 编辑 ] |
|
|
|
|
|
|
|
|
|
|
发表于 7-9-2008 10:21 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|