fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. int m, n, k;
  7. cin >> m >> n >> k;
  8. for (int i = 0; i < m; i++)
  9. {
  10. if (i % (k + 1) == 0)
  11. {
  12. for (int j = 0; j < n; j++)
  13. {
  14. cout << (j % (k + 1) == 0 ? "+" : "-");
  15. }
  16. }
  17. else
  18. {
  19. for (int j = 0; j < n; j++)
  20. {
  21. if (j % (k + 1) == 0)
  22. {
  23. cout << "|";
  24. }
  25. else
  26. {
  27. int a = (j % (k + 1) + i % (k + 1) - 1) % k;
  28. cout << (a == 0 ? k : a);
  29. }
  30. }
  31. }
  32. cout << endl;
  33. }
  34. return 0;
  35. }
Success #stdin #stdout 0s 3416KB
stdin
17 30 7
stdout
+-------+-------+-------+-----
|1234567|1234567|1234567|12345
|2345671|2345671|2345671|23456
|3456712|3456712|3456712|34567
|4567123|4567123|4567123|45671
|5671234|5671234|5671234|56712
|6712345|6712345|6712345|67123
|7123456|7123456|7123456|71234
+-------+-------+-------+-----
|1234567|1234567|1234567|12345
|2345671|2345671|2345671|23456
|3456712|3456712|3456712|34567
|4567123|4567123|4567123|45671
|5671234|5671234|5671234|56712
|6712345|6712345|6712345|67123
|7123456|7123456|7123456|71234
+-------+-------+-------+-----