⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ppoint.java

📁 实现文件的由大变小
💻 JAVA
字号:
import java.io.*;
 class point 
{
	int x,y;
	point()
	{
		x=0;
		y=0;
	}
	point(int n,int m)
	{
		x=n;
		y=m;
	}
	void setpoint(int n,int m)
	{
		x=n;
		y=m;
	}
	int distence()
	{
		return((int)Math.sqrt(x*x+y*y));
	}
    public String toString()
	{
		String s="("+x+","+y+")";
		return s;
	}
}
public class ppoint
{
	public static void main(String args[])
	{
		point p0=new point((int)(Math.random()*100),(int)(Math.random()*100));
		point p1=new point((int)(Math.random()*100),(int)(Math.random()*100));
		point p2=new point((int)(Math.random()*100),(int)(Math.random()*100));
		point p3=new point((int)(Math.random()*100),(int)(Math.random()*100));
		point p4=new point((int)(Math.random()*100),(int)(Math.random()*100));
		point p5=new point((int)(Math.random()*100),(int)(Math.random()*100));
		point p6=new point((int)(Math.random()*100),(int)(Math.random()*100));
		point p7=new point((int)(Math.random()*100),(int)(Math.random()*100));
		point p8=new point((int)(Math.random()*100),(int)(Math.random()*100));
		point p9=new point((int)(Math.random()*100),(int)(Math.random()*100));
		int i,j;
		point[] p={p0,p1,p2,p3,p4,p5,p6,p7,p8,p9};
		point temp;
		for(i=0;i<10;i++)
			for(j=0;j<9-i;j++)
			{
				if(p[j].distence()>=p[j+1].distence())
				{
					temp=p[j];
					p[j]=p[j+1];
					p[j+1]=temp;
				}
			}
		for(i=0;i<10;i++)
			System.out.print(p[i].distence()+" "+p[i]+" ");
	}
}


	

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -