Advertisement
Popkorn

Untitled

Oct 5th, 2014
873
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. public class MainClass
  2. {
  3. public static void main(String[] args)
  4. {
  5. int [] array = {0,1,0,1};
  6. int max = array[0];
  7. int min = array[0];
  8. for (int i=0; i<array.length; i++)
  9. {
  10. if (max<=array[i])
  11. max = array[i];
  12. if (min>=array[i])
  13. min = array[i];
  14. }
  15. for (int i=0; i<array.length; i++)
  16. {
  17. if (max==array[i])
  18. array[i]=min;
  19. else if (min==array[i])
  20. array[i]=max;
  21. }
  22. for (int i=0; i<array.length; i++)
  23. {
  24. System.out.print(array[i] + " ");
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement