Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public static void main(String[] args) {
  2.  
  3. Scanner beker=new Scanner(System.in);
  4. int t[][]=new int [100][2];//normál vektor
  5. double max=0;
  6. Random vel=new Random();
  7. int maxx=0;
  8. int maxy=0;
  9. for (int i = 0; i < 100; i++) {//feltöltés 0-199
  10. t[i][0]=vel.nextInt(200);
  11. t[i][1]=vel.nextInt(200);
  12. System.out.print("("+t[i][0]+", "+t[i][1]+") ");
  13. double hossz=Math.sqrt(Math.pow((t[i][0]), 2)+Math.pow((t[i][1]), 2));
  14. if (max<hossz) {
  15. max=hossz;
  16. maxx=t[i][0];
  17. maxy=t[i][1];
  18. }
  19. }
  20. System.out.println();
  21. System.out.println("A leghosszabb vektor hossza:"+max);
  22. System.out.println("("+maxx+", "+maxy+") ");//kiirja h melyek a leghosszabb vektor koordinátái
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement