fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. int main() {
  6. int m, n,k;
  7. double l=1;
  8. int counter = 0;
  9. cin >> m >> n >>k;
  10. for (int i=1; i<=n; i++){
  11. if(counter) l=k*2-(counter-1);
  12. if(l<2) counter=0;
  13. for (int j=1; j<=m; j++){
  14. if(l>k*2){
  15. l=1;
  16. }
  17. cout << ceil(l/2) ;
  18. l++;
  19. }
  20. cout << endl;
  21. counter++;
  22. }
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 3464KB
stdin
10 20 5
stdout
1122334455
5112233445
5511223344
4551122334
4455112233
3445511223
3344551122
2334455112
2233445511
1223344551
1122334455
5112233445
5511223344
4551122334
4455112233
3445511223
3344551122
2334455112
2233445511
1223344551