石蜡厂家是哪里:VC随机数产生的问题!
来源:百度文库 编辑:高考问答 时间:2024/05/08 11:31:08
我想让输出的结果是00.00的形式!
但是运行结果只是0.00,根本没有数字!
下面是我的程序.请高手给指点以下吧!
void CTestRandDlg::OnTestrand()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString str;
str.Format("%.2f");
p_StaticWnd = GetDlgItem(IDC_STATIC);
p_StaticWnd->SetWindowText(str);
UpdateData(FALSE);
}
/////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int RandomInt( int iMin, int iMax )
{
static int iInitSeed;
if( iMin >= iMax ) return iMin;
if( iInitSeed != 1 )
{
srand( (UINT)time( NULL ) );
iInitSeed = 1;
}
return iMin + rand() % ( iMax - iMin + 1 );
}
但是运行结果只是0.00,根本没有数字!
下面是我的程序.请高手给指点以下吧!
void CTestRandDlg::OnTestrand()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString str;
str.Format("%.2f");
p_StaticWnd = GetDlgItem(IDC_STATIC);
p_StaticWnd->SetWindowText(str);
UpdateData(FALSE);
}
/////////////////////////////////////////////////////////////
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int RandomInt( int iMin, int iMax )
{
static int iInitSeed;
if( iMin >= iMax ) return iMin;
if( iInitSeed != 1 )
{
srand( (UINT)time( NULL ) );
iInitSeed = 1;
}
return iMin + rand() % ( iMax - iMin + 1 );
}