fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. class Main{
  4. static int c = 0;
  5.  
  6. static void m( int[] a){
  7. int l = a.length,
  8. j = -1,
  9. i = -1;
  10. if(l < 1){
  11. return;
  12. }
  13. int[] x = new int[l-1];
  14. while(++j < c){
  15. p(" ");
  16. }
  17. for(; ++i < l; p(a[i] + " ")){
  18. if(i < l & i > 0){
  19. x[i - 1] = (a[i - 1] + a[i]) % 10;
  20. }
  21. }
  22. p("\n");
  23. c++;
  24. m(x);
  25. }
  26.  
  27. static <T> void p(T s){
  28. System.out.print(s);
  29. }
  30.  
  31. static void printAndReset(int[] a){
  32. m(a);
  33. c = 0;
  34. System.out.println();
  35. }
  36.  
  37. public static void main(String[] a){
  38. printAndReset(new int[]{ 7, 5, 0, 9 });
  39. printAndReset(new int[]{ 0 });
  40. printAndReset(new int[]{ 1, 2 });
  41. printAndReset(new int[]{ 8, 7 });
  42. printAndReset(new int[]{ 0, 0 });
  43. printAndReset(new int[]{ 1, 4, 2 });
  44. printAndReset(new int[]{ 0, 1, 0 });
  45. printAndReset(new int[]{ 1, 0, 0, 0 });
  46. printAndReset(new int[]{ 1, 2, 3, 4 });
  47. printAndReset(new int[]{ 1, 2, 3, 5, 8 });
  48. printAndReset(new int[]{ 9, 2, 4, 5, 3, 2, 2 });
  49. }
  50. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
7 5 0 9 
 2 5 9 
  7 4 
   1 

0 

1 2 
 3 

8 7 
 5 

0 0 
 0 

1 4 2 
 5 6 
  1 

0 1 0 
 1 1 
  2 

1 0 0 0 
 1 0 0 
  1 0 
   1 

1 2 3 4 
 3 5 7 
  8 2 
   0 

1 2 3 5 8 
 3 5 8 3 
  8 3 1 
   1 4 
    5 

9 2 4 5 3 2 2 
 1 6 9 8 5 4 
  7 5 7 3 9 
   2 2 0 2 
    4 2 2 
     6 4 
      0