作业帮 > 综合 > 作业

MFC中产生随机数MFC中随机产生20-40之间含有单位的随机数,使这些随机数之间的差不超过1,这些随机数分别在stat

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/07 05:15:41
MFC中产生随机数
MFC中随机产生20-40之间含有单位的随机数,使这些随机数之间的差不超过1,这些随机数分别在static
text显示,分别命名为IDC_10_1,IDC_10_2,IDC_10_3,IDC_10_4...,如:产生25℃,24℃,25℃,24℃,可以是小数,精确到小数点后2位
#include
#include
#include
void main( void )
{
int i;
/* Seed the random-number generator with current time so that
* the numbers will be different every time we run.
*/
srand( (unsigned)time( NULL ) );
/* Display 10 numbers. */
for( i = 0; i < 10;i++ )
printf( " %6d\n ", rand() );
}
再问: MFC里面,用static text显示,这个MFC随机数也不对吧,MFC里面用 static text显示是这样的吧,this->SetDlgItemInt(IDC_10_2, (rand()) % 10, TRUE);IDC_10_2是static text的名称