我现在想产生一个Num[200]的数据,然后读入文件。由于初学,希望用代码回复
解决方案 »
- 将socket 封装到dll中 编译问题
- Edit控件中的内容改变,其他控件响应
- 请教vc图形问题
- STDMETHODIMP CImpMonikerCallback::OnProgress 请问怎么设置?
- CListCtrl新插入的item是在前面还是在后面?
- 大型服务器至少应该满足多少并发连接?
- 求够《Windows游戏编程大全》和光盘,谢谢大家!~~~~~~~~~~~~
- 请问错在哪里??
- 关于隐藏模式对话框
- 急问:如何使这个CPropertySheet非模态显示? 已困扰了我两周得问题,我还要迷惑多久??
- 真诚求帮我看看下面导出函数方式对吗?又一个通宵
- dialog界面设计,分割线是如何放置进来的?
#define MAX_COUNT 200
int Num[MAX_COUNT] = {0}; CString strText(_T(""));
CString strTmp(_T("")); srand((int)time(NULL));
for(int i=0; i<MAX_COUNT; i++)
{
Num[i] = rand();
strTmp.Format(_T("%d "), Num[i]);
strText += strTmp;
if(0 == (i+1)%10)
{
strText += _T("\r\n");
}
} try
{
CStdioFile file;
file.Open(_T("F:\\11.txt"), CFile::modeCreate | CFile::modeWrite);
file.WriteString(strText);
file.Close();
}
catch (CFileException* e)
{
e->ReportError();
e->Delete();
}
long int a[200];
ofstream fout("random.txt");
srand((unsigned)time(NULL));
for (int i=0;i<200;i++)
{
long int temp=(rand()*rand())%MAX;
a[i]=temp;
fout<<temp<<endl;
}
cout<<"随机数产生完毕!"<<endl;
fout << flush;
fout.close();