fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. int f(int k, int n) {
  4. for (int i = 1; i < n; i++) {
  5. k = k / 10;
  6. if (k == 0) return -1;
  7. }
  8. return k % 10;
  9. }
  10. int main() {
  11. int a, b, c, d, e;
  12. cin >> a >> b >> c >> d >> e;
  13. cout << f(a, 1) << " " << f(a, 2) << " " << f(a, 3) << " " << f(a, 4) << " " << f(a, 5) << endl;
  14. cout << f(b, 1) << " " << f(b, 2) << " " << f(b, 3) << " " << f(b, 4) << " " << f(b, 5) << endl;
  15. cout << f(c, 1) << " " << f(c, 2) << " " << f(c, 3) << " " << f(c, 4) << " " << f(c, 5) << endl;
  16. cout << f(d, 1) << " " << f(d, 2) << " " << f(d, 3) << " " << f(d, 4) << " " << f(d, 5) << endl;
  17. cout << f(e, 1) << " " << f(e, 2) << " " << f(e, 3) << " " << f(e, 4) << " " << f(e, 5);
  18. return 0;
  19. }
Success #stdin #stdout 0s 5324KB
stdin
123 5432 654 21 54
stdout
3 2 1 -1 -1
2 3 4 5 -1
4 5 6 -1 -1
1 2 -1 -1 -1
4 5 -1 -1 -1