fork download
  1. #include <iostream>
  2.  
  3. int main() {
  4. int rows = 6;
  5. int cols = 31;
  6.  
  7. for (int i = 1; i <= rows; i++) {
  8. for (int j = 1; j <= cols; j++) {
  9. if (i == 1 || i == rows || j == 1 || j == cols) {
  10. std::cout << j << " ";
  11. } else {
  12. if (j % 2 == 1 && i % 2 == 1) {
  13. std::cout << j << " ";
  14. } else {
  15. std::cout << " ";
  16. }
  17. }
  18. }
  19. std::cout << std::endl;
  20. }
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 
1                                                           31 
1   3   5   7   9   11   13   15   17   19   21   23   25   27   29   31 
1                                                           31 
1   3   5   7   9   11   13   15   17   19   21   23   25   27   29   31 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31