Facebook
From Kamil Kucharczyk, 2 Months ago, written in C++.
Embed
Download Paste or View Raw
Hits: 41
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cstdlib>
  4.  
  5. int main()
  6. {
  7.     int drawn, row=1,last;
  8.     srand(time(NULL));
  9.     do {
  10.             drawn = rand()%2;
  11.             std::cout<<drawn<<std::endl;
  12.             if(drawn==last)row++;
  13.             else if (drawn!=last) row=1;
  14.             last=drawn;
  15.  
  16.     } while (row!=3);
  17.     std::cout<<"Liczba "<<last<<" zostala wylosowana 3 razy pod rzad!" << std::endl;
  18.     return 0;
  19. }
  20.