Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- Scanner beker=new Scanner(System.in);
- int t[][]=new int [100][2];//normál vektor
- double max=0;
- Random vel=new Random();
- int maxx=0;
- int maxy=0;
- for (int i = 0; i < 100; i++) {//feltöltés 0-199
- t[i][0]=vel.nextInt(200);
- t[i][1]=vel.nextInt(200);
- System.out.print("("+t[i][0]+", "+t[i][1]+") ");
- double hossz=Math.sqrt(Math.pow((t[i][0]), 2)+Math.pow((t[i][1]), 2));
- if (max<hossz) {
- max=hossz;
- maxx=t[i][0];
- maxy=t[i][1];
- }
- }
- System.out.println();
- System.out.println("A leghosszabb vektor hossza:"+max);
- System.out.println("("+maxx+", "+maxy+") ");//kiirja h melyek a leghosszabb vektor koordinátái
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement