Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. 0 2 4 6 7
  2. 8 9 10 11 12
  3.  
  4. 0 2 4 2 0
  5. 8 9 10 9 8
  6.  
  7. 0 2 4 2 2
  8. 8 9 10 8 8
  9.  
  10. import java.util.Scanner;
  11. public class Mirror {
  12. public static void main (String [] args)
  13. {
  14.  
  15. Scanner kb = new Scanner (System.in);
  16. System.out.println("Please enter number of rows: ");
  17. int rows = kb.nextInt();
  18.  
  19. System.out.println("Please enter number of columns:");
  20. int columns = kb.nextInt();
  21.  
  22. int [][] mirror = new int [rows][columns];
  23.  
  24. int sum =0;
  25.  
  26. for (int r = 0; r<mirror.length; r++)
  27. {
  28. for (int c = 0; c<mirror[r].length ; c++)
  29. {
  30. mirror[r][c]= sum;
  31.  
  32. sum= sum+2;
  33. }
  34. }
  35.  
  36. for (int r = 0; r<mirror.length; r++)
  37. {
  38. for (int c = 0; c<mirror[r].length ; c++)
  39. {
  40. System.out.print (mirror[r][c]+ " ");
  41. }
  42. System.out.println();
  43.  
  44. }
  45.  
  46. int add = 0;
  47. for (int r = 0; r<mirror.length; r++)
  48. {
  49. for (int c = mirror[r].length/2 +1; c<mirror[r].length ; c++)
  50. {
  51. for (int x= 0; x<mirror[r].length/2; x=x++)
  52. {
  53. mirror[r][c] = mirror [r][x];
  54.  
  55. }
  56.  
  57. }
  58. }
  59.  
  60. System.out.println();
  61.  
  62. for (int r = 0; r<mirror.length; r++)
  63. {
  64. for (int c = 0; c<mirror[r].length ; c++)
  65. {
  66. System.out.print (mirror[r][c]+ " ");
  67. }
  68. System.out.println();
  69.  
  70. }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement