package com.homework;
import java.util.Scanner;
/*
作者:mengling 2227287556@qq.com
时间:2021.3.27
*/
public class HomeWork1 {
public static void main(String[] args) {
String []arr=new String[5];
Scanner input = new Scanner(System.in);
System.out.println("请输入五个汉字");
for (int i = 0; i < 5; i++) {
arr[i]=input.next();
}
for (int i = 4; i >= 0; i--) {
System.out.println(arr[i]);
}
}
}
package com.homework;
/*
作者:mengling 2227287556@qq.com
时间:2021.3.27
*/
public class Homework2 {
public static void main(String[] args) {
boolean Ling = false ;
int []array = new int[]{1,3,-1,5,-2};
int temp=0;
for (int i = 0; i < array.length; i++) {
for (int j = 1; j < (array.length-i); j++) {
if (array[j-1]>array[j]){
temp = array[j-1];
array[j-1]=array[j];
array[j]=temp;
Ling=true;
}
}
if (!Ling){
break;
}
}
for (int i = 0; i < 5; i++) {
System.out.println(array[i]);
}
}
}
package com.homework;
import java.util.Scanner;
/*
作者:mengling 2227287556@qq.com
时间:2021.3.27
*/
public class HomeWork3 {
public static void main(String[] args) {
int not = 0,yes = 0,one = 0,two = 0,three = 0;
int[]shuzu=new int[10];
Scanner input = new Scanner(System.in);
System.out.println("请输入十个数");
for (int i = 0; i < 10; i++) {
shuzu[i]=input.nextInt();
if (shuzu[i]==1||shuzu[i]==2||shuzu[i]==3){
yes++;
}
else {
not++;
}
if (shuzu[i]==1){
one++;
}
if (shuzu[i]==2){
two++;
}
if (shuzu[i]==3){
three++;
}
}
System.out.print("输入的十个数为:");
for (int i = 0; i < 10; i++) {
System.out.print(shuzu[i]+" ");
}
System.out.println();
System.out.println("输入1的个数:"+one);
System.out.println("输入2的个数:"+two);
System.out.println("输入3的个数:"+three);
System.out.println("非法数字的个数:"+not);
}
}