求 用C++怎么编写出程序为 从1到100中随机选出一个数。

如题所述

第1个回答  2013-12-19
#include <stdlib.h>
#include <stdio.h>
#include <time.h> void main()
{
int k;
srand((unsigned)time(NULL));
k= rand()%100 + 1;
printf("%d ", k ); }
第2个回答  2013-12-19
加入头文件 time.h int _randmaxsrand((unsigned)time(NULL));cout<<"Input a upper limit to create random numbers:";cin>>_randmax;cout<<endl;for(int i = 0 ; i < 10 ; i++) cout<<(int)rand()%100
相似回答