fork download
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. #include <string>
  5.  
  6. int main()
  7. {
  8. std::srand( std::time(nullptr) ) ;
  9.  
  10. std::string five_x_seven ;
  11.  
  12. for( int i = 0 ; i < 5 ; ++i ) // 5 lines
  13. {
  14. for( int j = 0 ; j < 7 ; ++j ) // write 7 random digits per line
  15. {
  16. five_x_seven += std::rand() % 10 + '0' ;
  17. five_x_seven += ' ' ;
  18. }
  19. five_x_seven += '\n' ; // and end with a new line
  20. }
  21.  
  22. std::cout << five_x_seven ;
  23. }
  24.  
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
5 1 7 9 6 0 5 
6 8 1 4 9 6 6 
2 6 0 5 2 1 7 
9 8 0 0 7 7 2 
4 7 8 9 0 7 0