fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int DigitN(int K, int N) {
  5. for (int i = 1; i < N; i++) {
  6. K /= 10;
  7. }
  8. if (K == 0) return -1;
  9. return K % 10;
  10. }
  11. int main() {
  12. int K1, K2, K3, K4, K5;
  13. cin >> K1 >> K2 >> K3 >> K4 >> K5;
  14. int numbers[5] = { K1, K2, K3, K4, K5 };
  15. for (int i = 0; i < 5; i++) {
  16. for (int N = 1; N <= 5; N++) {
  17. cout << DigitN(numbers[i], N) << " ";
  18. }
  19. cout << endl;
  20. }
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5292KB
stdin
234 123 78 43 2
stdout
4 3 2 -1 -1 
3 2 1 -1 -1 
8 7 -1 -1 -1 
3 4 -1 -1 -1 
2 -1 -1 -1 -1