Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. import java.util.*;
  2. class gf{
  3. public static void main(String [] args)
  4. {
  5. int s,i;
  6. Scanner w=new Scanner(System.in);
  7. System.out.println("enter the size");
  8. s=w.nextInt();
  9. int n[]=new int[s];
  10. System.out.println("enter the elements");
  11. for(i=0;i<s;i++)
  12. {
  13. n[i]=w.nextInt();
  14. }
  15. System.out.println("those elements are");
  16. for(i=0;i<s;i++)
  17. {
  18. System.out.print(n[i]+" ");
  19. }
  20. System.out.println();
  21. int max=n[0];
  22. for(i=0;i<s-1;i++)
  23. {
  24. if(max<n[i+1])
  25. {
  26. max=n[i+1];
  27. }
  28. }
  29. System.out.println("maximum number is"+max);
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement