fork(9) download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. int main()
  5. {
  6. const int indent = 20 , letters = 6;
  7. int extra= 0;
  8. std::cout << std::setfill( ' ' );
  9. std::cout << "Number" << std::setw( indent ) << "Square" << std::endl;
  10.  
  11. for( int i = 0; i < 20; ++i )
  12. {
  13. if( i < 10 ) extra = 0;
  14. else if( i < 100 ) extra = 1;
  15. std::cout << i << std::setw( indent - 1 - extra ) << ' ';
  16. std::cout << i * i << std::endl;
  17. }
  18. return( 0 );
  19. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
Number              Square
0                   0
1                   1
2                   4
3                   9
4                   16
5                   25
6                   36
7                   49
8                   64
9                   81
10                  100
11                  121
12                  144
13                  169
14                  196
15                  225
16                  256
17                  289
18                  324
19                  361