第1个回答 2018-08-09
c++ 程序,按 Ctrl+c 退出,enter 继续。
#include<iostream>
using namespace std;
#include<stdio.h>
#include <time.h>
int main()
{
int v;
srand(time(0));
while(1){
v=rand()%101;
if (v<50) printf("%d < 50\n",v);
else printf("%d >= 50\n",v);
getchar();
}
return 0;
}
第2个回答 2018-08-09
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main( )
{
srand( (unsigned)time(NULL) );
char op;
int randNum;
do{
cin.get(op);
if( op == '\n' ){
randNum = rand()%101;
if( randNum < 50 ){
cout << randNum << " 小于\n";
}else{
cout << randNum << " 大于\n";
}
}else{
break;
}
}while( true );
return 0;
}