1.cpp #include #include using namespace std; main() { int m; srand(time(NULL));//产生随机数种子 m=rand()%1000+1; cout<<"***猜数字游戏***"< cout<<"请输入你猜想的合理的商品价格;"; int n; cin>>n; while(n>1000||n<1)//数据合法性判断 { ...
随机数函数rand和种子函数srand的使用 #include<stdlib.h>#include<stdio.h>#includeint main(){ int i; time_t t; srand((unsigned)time(&t)); printf("ten random numbers from 0 to 99\n\n"); for(i = 0; i<10; i++) { printf("%d\n",rand()%100); }}posted on ...
随机数函数rand和种子函数srand的使用 #include<stdlib.h>#include<stdio.h>#includeint main(){ int i; time_t t; srand((unsigned)time(&t)); printf("ten random numbers from 0 to 99\n\n"); for(i = 0; i<10; i++) { printf("%d\n",rand()%100); }}posted on ...