import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.math.BigDecimal;
import javax.swing.JFrame;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class test {
public static void main(String[] args)
{
System.out.println("start");
System.err.println("asdadads");//输出括号里面的东西,“ ”中间是字符串
//getPut();
//inlog();
//passmade();
//numberjo();
//floatmath();
//movesite();
//exchangeWithNoThree();
//CheckLogin();
//a();
//switchcase();
//whileup();
//yanghuiTtriangle();
//multiplicationTable();
//multiply20jie();
//printdimo(6);
//useForeach();
//mathForm();
minVarnum();
//madeFrame();
}
public static void a()
{
System.out.println("1");
}
public static void getPut()
{
Scanner sca=new Scanner(System.in);
System.out.print("inout what you want to write");
String line=sca.nextLine();
System.out.println("\n this is what you saied:"+line);
}
public static void inlog()
{
try{
PrintStream out=System.out;
PrintStream ps=new PrintStream("./log.txt");
System.setOut(ps);
int age=18;
System.out.println("we get the age 18");
System.setOut(out);
System.out.println("all we get is in log.text");
}catch(FileNotFoundException e)
{
e.printStackTrace();
}
}
public static void passmade()
{
Scanner scanr=new Scanner(System.in);
System.out.println("inout what you want pass");
String password=scanr.nextLine();
char[] array=password.toCharArray();
for(int i=0;i<array.length;i++)
{
array[i]=(char)(array[i]^98512);//0是错误的
}
System.out.println("we pass you message with spicel ways that no one will catch it");
System.err.println(new String(array));
}
public static void numberjo()
{
Scanner sca=new Scanner(System.in);
System.out.println("intput a number");
long num=sca.nextLong();
String cheek=(num%2==0)?"这是oushu":"奇数";
System.out.println(cheek);
}
public static void floatmath()
{
double money=2;
double price=1.1;
double result=money-price;
System.out.println("simple math calculation");
System.out.println("you will pay"+result);
BigDecimal money1=new BigDecimal("2");
BigDecimal price1=new BigDecimal("1.1");
BigDecimal result1=money1.subtract(price1);
System.out.println("accuracy calculation");
System.out.println("you will pay:"+result1);
}
public static void movesite()
{
Scanner scan=new Scanner(System.in);
System.out.println("input an int");
long num=scan.nextLong();
System.out.println("2^1 times get is:"+(num<<1));
System.out.println("2^2 times get is"+(num<<2));
System.out.println("2^3 times get is"+(num<<3));
System.out.println("2^4 times get is"+(num<<4));
}
public static void exchangeWithNoThree()
{
Scanner scan=new Scanner(System.in);
System.out.println("input first var");
long a=scan.nextLong();
System.out.println("input second var");
long b=scan.nextLong();
System.out.println("(a)"+a+"(b)"+b);
a=a^b;
b=b^a;
a=a^b;
System.out.println("(a)"+a+"(b)"+b);
}
public static void CheckLogin()
{
Scanner scan=new Scanner(System.in);
System.out.println("input username");
String username=scan.nextLine();
System.out.println("input password");
String password=scan.nextLine();
if(!username.equals("wyj"))
{
System.out.println("no exist");
}else if(!password.equals("0512"))
{
System.out.println("wrong password");
}else
{
System.out.println("welcome");
}
}
public static void switchcase()
{
Scanner scan=new Scanner(System.in);
System.out.println("input name");
String name=scan.nextLine();
System.out.println("input position");
String position=scan.nextLine();
float money=1206;
switch(position.hashCode())
{
case 3254818:
case 2301506:
case 2269730:
System.out.println("weclome to java pro group");
break;
case 3104:
case 2112:
System.out.println("weclome to c# pro group");
}
}
public static void whileup()
{
String[] a=new String[]{"123","123123","121313","123213","123","123"};
int index=0;
int waite=0;
while(index<a.length)
{
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
System.out.println(a[index++]);
}
}
public static void yanghuiTtriangle()
{
int triangle[][]=new int[8][];
//遍历第一层
for(int i=0;i<triangle.length;i++)
{
triangle[i]=new int[i+1];
for(int j=0;j<=triangle[i].length-1;j++)
{
//evaluation two side of array row
if(i==0||j==0||j==triangle[i].length-1)
{
triangle[i][j]=1;
}
else
{
triangle[i][j]=triangle[i-1][j]+triangle[i-1][j-1];
}
System.out.print(triangle[i][j]+"\t");
}
System.out.println();
}
}
public static void multiplicationTable()
{
for(int i=1;i<=9;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(j+"*"+i+"="+i*j+"\t");
}
System.out.println();
}
}
public static void multiply20jie()
{
BigDecimal sum=new BigDecimal(0.0);
BigDecimal factorial=new BigDecimal(1.0);
int i=1;
while(i<20)
{
sum=sum.add(factorial);
++i;
factorial=factorial.multiply(new BigDecimal(1.0/i));
}
System.out.println("1+1/2!+1/3!.......+ 1/20!="+sum);
}
public static void printdimo(int size)
{
if(size%2==0)
{
size++;// 计算菱形大小,左右对称
}
for(int i=0;i<size/2+1;i++)
{
for(int j=size/2+1;j>i+1;j--)
{
System.out.print(" ");//第i行的左边空白
}
for(int j=0;j<2*i+1;j++)//此时j是第i行行空白后的第j位
{
if(j==0||j==2*i)
{
System.out.print("*");//左右边界
}else
{
System.out.print(" ");//中间空白
}
}
System.out.println("");
}
for(int i=size/2+1;i<size;i++)
{
for(int j=0;j<i-size/2;j++)//下半左边空白
{
System.out.print(" ");
}
for(int j=0;j<2*size-1-2*i;j++)
{
if(j==0||j==2*(size-i-1))
{
System.out.print("*");
}else
{
System.out.print(" ");
}
}
System.out.println("");
}
}
public static void useForeach()
{
List<String>list=new ArrayList<String>();
list.add("abs");
list.add("ara");
list.add("sad");
System.out.print("foreach begin ");
for(String string:list)
{
System.out.print(string+" ");
}
System.out.println();
String[]strs=new String[list.size()];
list.toArray(strs);//列表转数组
System.out.print("foreach numberarray ");
for(String string:strs)
{
if(string=="ara")
{
//continue;
}else if(string=="sad")
{
System.out.print("we get the comend to stop ");
}else
System.out.print(string+" ");
}
int max=Integer.MAX_VALUE;
System.out.println(max);//加1进位为0
System.out.println(max+1);
}
public static void mathForm()
{
JFrame frame=new JFrame("xx的计算器"); //创建一个窗体标题
frame.setLayout(new GridLayout(6,3,3,3)); //表格布局7*3,水平和垂直间距为3
JPanel pan = new JPanel(new GridLayout(1,3,3,3)); //创建一个面板容器,指定为表格布局,1*3,水平和垂直间距为3
JButton b1=new JButton("查看"); //
JButton b2=new JButton("编辑"); //
JButton b3=new JButton("帮助"); //创建三个按钮,并给按钮上添加文字
pan.add(b1); //
pan.add(b2); //
pan.add(b3); //把三个按钮添加到pan面板容器中
frame.add(pan); //把pan面板容器添加到窗体
JPanel pan1= new JPanel(new GridLayout(1,4,3,3)); //创建pan1面板容器,指定为表格布局,1*4,水平垂直间距为3
JPanel pan2= new JPanel(new GridLayout(1,4,3,3)); //创建pan2面板容器,指定为表格布局,1*4,水平垂直间距为3
JPanel pan3= new JPanel(new GridLayout(1,4,3,3)); //创建pan3面板容器,指定为表格布局,1*4,水平垂直间距为3
JPanel pan4= new JPanel(new GridLayout(1,4,3,3)); //创建pan4面板容器,指定为表格布局,1*4,水平垂直间距为3
JTextField h1=new JTextField(); //创建一个单行文本框h1
frame.add(h1); //添加单行文本框到窗体
String str[]={"7", "8", "9", "/",}; //定义一个STR数组,并初始化
JButton but=null; //创建一个空按钮模型but
for(int i=0;i<4;i++){
but = new JButton(""+str[i]);
pan1.add(but) ; //利用循环逐个添加到pan1面板容器中
}
String str2[]={ "4", "5", "6", "*", }; //定义数组str2数组,并初始化
JButton but2=null; //创建按钮模型
for(int i=0;i<4;i++){
but2=new JButton(""+str2[i]);
pan2.add(but2); //把数组中的按钮添加到pan2容器中
}
String str3[]={"1", "2", "3", "-",}; //定义数组str3数组,并初始化
JButton but3=null;
for(int i=0;i<4;i++){
but3 = new JButton(""+str3[i]);
pan3.add(but3) ; //把数组中的按钮添加到pan3容器中
}
String str4[]={ "0", ".", "=", "+"}; //定义数组str4数组,并初始化
JButton but4=null;
for(int i=0;i<4;i++){
but4 = new JButton(""+str4[i]);
pan4.add(but4) ; //把数组中的按钮添加到pan4容器中
}
frame.add(pan1); //添加pan1容器到窗体中
frame.add(pan2); //添加pan2容器到窗体中
frame.add(pan3); //添加pan3容器到窗体中
frame.add(pan4); //添加pan4容器到窗体中
frame.pack(); //设置窗体大小以内容大小决定
frame.setVisible(true); //显示窗体
}
public static void minVarnum()
{
JFrame frame=new JFrame("最小值"); //创建一个窗体标题
frame.setSize(500,500);
frame.setBackground(Color.WHITE);//表格布局7*3,水平和垂直间距为3
frame.setLocation(300, 200);
JTextField h1=new JTextField();
JButton b1=new JButton("查看");
b1.setBounds(10,10,100,21);
frame.add(b1);
frame.add(h1);
frame.setVisible(true);
b1.setVisible(true);
}