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

📄 sortbetter.java

📁 是自己在ECPLISE下做的一个简单的排序程序,有兴趣的可以看下.
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import java.io.*;
class sortBetter{
	public static void main(String args[]){
		new sort();
	}
}
class sort extends Frame implements ActionListener{
	Label show=new Label("count");
	Label show2=new Label("result");
	TextField tf1=new TextField(20);
	TextField tf2=new TextField(20);
	Button bt1=new Button("sort start");
	Button bt2=new Button("end");
	int[] array=new int[10];
    int count=1;
	public sort(){
		super("sort");
		for(int i=0;i<10;i++){
			array[i]=0;
		}
		setLayout(new FlowLayout());
		add(show);
		add(tf1);
		add(show2);
		add(tf2);
		add(bt1);                                   //traole may happen on the  static array
		add(bt2);                                   //and when the array is sorted by the tf1,it is OK
		tf1.setText("请输入第1个数");
		tf1.addActionListener(this);
		tf2.addActionListener(this);
		bt1.addActionListener(this);
		bt2.addActionListener(this);
		setSize(500,200);
		show();
	}
	
	
	public void actionPerformed(ActionEvent e){
		
		if(e.getSource()==tf2){
				array[count-1]=Integer.parseInt(tf2.getText());
				tf2.setText("");
				count=count+1;
				if(count<11){
				    tf1.setText("请输入第"+count+"数");
				}

		}
	    if(e.getSource()==bt1){
		     for(int i=0;i<10;i++)
		     	   for(int j=0;j<9-i;j++){
		     		  if(array[j]<array[j+1]){
		     		 	 int c=array[j];
		     			 array[j]=array[j+1];
		     			 array[j+1]=c;
		     		}
		     	}
	      tf2.setText("Max: "+array[0]+"  Min: "+array[9]);
	   }
	   if(e.getSource()==bt2){
	   	dispose();
	   	System.exit(0);
	   }
	}
}

⌨️ 快捷键说明

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