RosettaCodeData/Task/Loops-Break/C++/loops-break.cpp

17 lines
333 B
C++
Raw Permalink Normal View History

2013-04-10 21:29:02 -07:00
#include <iostream>
#include <ctime>
#include <cstdlib>
2018-06-22 20:57:24 +00:00
int main(){
srand(time(NULL)); // randomize seed
while(true){
const int a = rand() % 20; // biased towards lower numbers if RANDMAX % 20 > 0
std::cout << a << std::endl;
if(a == 10)
break;
const int b = rand() % 20;
std::cout << b << std::endl;
}
return 0;
2013-04-10 21:29:02 -07:00
}