package org.test;
import java.util.Arrays;
import java.util.Scanner;
public class TestMain {
static Scanner scanner = new Scanner(System.in);
public static void test1(){
String left = "黑桃10";
String right="红桃8";
String temp = "";
temp = left;
left = right;
right = temp;
System.out.println("左边"+left);
System.out.println("右边"+right);
}
public static void test2(){
System.out.println("请输入第一个数:");
int a = scanner.nextInt();
System.out.println("请输入第二个数:");
int b = scanner.nextInt();
System.out.println("请输入第三个数:");
int c = scanner.nextInt();
int x=0;
if(a>b)
{
x=a;
a=b;
b=x;
}
if(a>c)
{
x=a;
a=c;
c=x;
}
if(b>c)
{
x=b;
b=c;
c=x;
}
System.out.println(a+","+b+","+c);
}
public static void test4(){
int sum=0;
for(int i=2;i<=100;i+=2){
sum+=i;
}
System.out.println(sum);
}
public static void test5(){
int i = 0;
int sum = 0;
while( i<=100){
i++;
sum+=i;
}
System.out.println("总和是:"+sum);
}
public static void test6(){
int max = 0,min = 0,nums = 1,i = 0;
System.out.println("请输入第1个数:");
nums = scanner.nextInt();
max = nums;
min = nums;
for(i = 1;nums != 0;i++){
System.out.println("请输入第"+(i+1)+"个数:");
nums = scanner.nextInt();
if(nums != 0){
if(nums > max){
max = nums;
}
if(nums < min){
min = nums;
}
}
}
System.out.println("最大值为:"+max);
System.out.println("最小值为:"+min);
}
public static void test7(){
int sum = 0;
for (int i = 1; i <=100; i++) {
if(i%2==0){
continue;
}else{
sum+=i;
}
}
System.out.println("和是:"+sum);
}
public static void test8(){
int num = (int)(Math.random()*100);
System.out.println("随机数是:"+num);
System.out.println("请猜数字:");
int cai = scanner.nextInt();
int count = 1;
do {
if(cai>num){
System.out.println("猜的太大了");
}else if(cai<num){
System.out.println("猜的太小了");
}else{
System.out.println("终于猜对了!");
break;
}
count++;
System.out.println("请猜数字:");
cai = scanner.nextInt();
} while (cai!=num);
System.out.println("猜的次数是:"+count);
switch (count) {
case 1:
System.out.println("你太聪明了!");
break;
case 2:
case 3 :
case 4:
case 5:
System.out.println("不错,再接再厉!");
break;
default:
System.out.println("太笨了");
break;
}
}
public static void test9(){
int num[] = new int [10];
for (int i = 0; i < num.length; i++) {
System.out.println("请输入第"+(i+1)+"个数:");
num[i] = scanner.nextInt();
}
Arrays.sort(num);
for (int i =num.length-1;i>=0 ;i--) {
System.out.println(num[i]);
}
}
public static void test10(){
int x=0;
int y=0;
for(x=0;x<=35;x++) {
y=35-x;
if(2*x+4*y==94)
System.out.println("鸡"+x+"只,兔"+y+"只");
}
}
public static void test11(){
System.out.println("请输入一个正整数:");
int num = scanner.nextInt();
boolean flag = false;
if(num<=1){
System.out.println("他不是素数!");
}else{
for (int i = 2; i < num; i++) {
if(num%i==0){
flag = true;
}
}
if(flag==true){
System.out.println(num+"不是素数");
}else{
System.out.println(num+"是素数");
}
}
}
public static void test12(){
int a = 2,b= 1,c= 0,sum=0;
for (int i = 1; i <=20; i++) {
sum = a/b;
c = a+b;
b = a;
a = c;
}
System.out.println("和为\t"+sum);
}
public static void main(String[] args) {
test12();
}
}