Advertisement
JWhy

Java for loop cuboid

Aug 20th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. int start_x = 100;
  2. int end_x = 120;
  3. if(start_x > end_x){
  4.   int buffer_x = start_x;
  5.   start_x = end_x;
  6.   end_x = buffer_x;
  7. }
  8.  
  9. int start_y = 30;
  10. int end_y = 90;
  11. if(start_y > end_y){
  12.   int buffer_y = start_y;
  13.   start_y = end_y;
  14.   end_y = buffer_y;
  15. }
  16.  
  17. for(int x = start_x; x <= end_x; x++){    
  18.     for(int y = start_y; y <= end_y; y++){    
  19.         sender.sendMessage("Current coordinate: X=" + x + " Y=" + y);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement