fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int MAXVAL = 100, COLS=3;
  7.  
  8. int display;
  9.  
  10. int nearest3;
  11. if (MAXVAL % 3 > 0)
  12. nearest3 = MAXVAL + (3 - MAXVAL % 3);
  13. else
  14. nearest3 = MAXVAL;
  15.  
  16. cout << "nearest3 is " << nearest3 << endl;
  17.  
  18. int ROWS = nearest3/COLS;
  19. cout << "ROWS is " << ROWS << endl;
  20.  
  21. for(int r=1; r<=ROWS; r++)
  22. {
  23. //for(int c=1; c<=COLS; c++)
  24. //{
  25. if(r+(nearest3/COLS)*2 <= MAXVAL)
  26. display = 1;
  27. else
  28. display = 0;
  29.  
  30. if (display)
  31. cout << r << " " << r+(nearest3/COLS) << " " << r+(nearest3/COLS)*2 << endl ;
  32. else
  33. cout << r << " " << r+(nearest3/COLS) << " " << endl ;
  34.  
  35. //}
  36. }
  37.  
  38. // your code goes here
  39. return 0;
  40. }
  41.  
Success #stdin #stdout 0s 3096KB
stdin
Standard input is empty
stdout
nearest3 is 102
ROWS is 34
1 35 69
2 36 70
3 37 71
4 38 72
5 39 73
6 40 74
7 41 75
8 42 76
9 43 77
10 44 78
11 45 79
12 46 80
13 47 81
14 48 82
15 49 83
16 50 84
17 51 85
18 52 86
19 53 87
20 54 88
21 55 89
22 56 90
23 57 91
24 58 92
25 59 93
26 60 94
27 61 95
28 62 96
29 63 97
30 64 98
31 65 99
32 66 100
33 67 
34 68