fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6. int m, n, k;
  7. cin >> m >> n >> k;
  8. for (int i = 1; i <= m; i++) {
  9. int num = i % (2*k) <= k ? i % (2*k) : 2*k - i % (2*k);
  10. if (num == 2*k) num = 0;
  11. bool up = i % (2*k) < k ? true : false;
  12. for (int j = 1; j <= n; j ++) {
  13. if (num == 0) cout << "+";
  14. else cout << num;
  15. if (num == k) up = false;
  16. else if (num == 0) up = true;
  17. num = up ? num + 1 : num - 1;
  18. }
  19. cout << endl;
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 3416KB
stdin
7 14 10
stdout
123456789109876
234567891098765
345678910987654
456789109876543
567891098765432
678910987654321
78910987654321+