package jb;
import java.util.Scanner;
public class jb {
public static void main(String[] args) {
int x[]={7,4,8,1,9};
jc(x);
for (int i : x) {
System.out.print(i+"\t");
}
}
public static void jc(int[]x){
int a=0;
for (int i = x.length-1; i>0; i--) {
for (int j = 0; j < i; j++) {
if(x[j]>x[i]) {
a=x[j];
x[j]=x[i];
x[i]=a;
}
}
}
}
}
package jb;
import java.util.Scanner;
public class jb {
public static void main(String[] args) {
returnbb();
}
public static void returnbb(){
System.out.println("输入一个数");
Scanner input=new Scanner(System.in);
jc();
}
public static void jc(){
Scanner input=new Scanner(System.in);
int a=input.nextInt();
int sum=1;
for(int i=1;i<=a;i++){
sum=sum*i;
}
System.out.println("阶乘为"+sum);
returnbb();
}
}
package jb;
import java.util.Scanner;
public class jb {
public static void main(String[] args) {
returnbb();
}
public static void returnbb(){
System.out.println("输入年份");
Scanner input=new Scanner(System.in);
jc();
}
public static void jc(){
Scanner input=new Scanner(System.in);
int a=input.nextInt();
if(a%4==0||a%400==0&&a%100!=0){
System.out.println("闰年");}
else {
System.out.println("不是闰年");
}
returnbb();
}
}
package jby;
import java.util.Scanner;
import java.util.Random;
public class jby {
public static void main(String[] args) {
mainMenu();
}
public static void mainMenu(){
Scanner input=new Scanner(System.in);
System.out.println("欢迎使用本系统");
System.out.println("1.登录");
System.out.println("2.注册");
System.out.println("3.幸运抽奖");
System.out.println("4.退出");
System.out.println("请选择");
int i=input.nextInt();
switch(i){
case 1:
dengru();
break;
case 2:
zuce();
break;
case 3:
choujiang();
case 4:
tuicu();
}
}
public static void returnMain(){
Scanner input=new Scanner(System.in);
System.out.println("是否返回主菜单?");
if(input.next().equalsIgnoreCase("Y"))
mainMenu();
else
System.out.println("谢谢使用");
}
public static void dengru() {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
System.out.println("输入要注册的用户名");
String uname=input.next();
System.out.println("输入注册密码");
String upwd=input.next();
System.out.println("注册成功");
returnMain();
}
public static void zuce(){
Scanner input=new Scanner(System.in);
System.out.println("输入用户名");
String uname=input.next();
System.out.println("输入密码");
String upwd=input.next();
if(uname.equals("zs")&&upwd.equals("123")){
System.out.println("ok");
}else{
System.out.println("fail");
}
returnMain();
}
public static void choujiang() {
// 输入四位会员卡号,如果百位数等于随机数,幸运会员。否则不是。同时也要询问是否返回主菜单
System.out.println("输入四位会员卡号");
Scanner input=new Scanner(System.in) ;
int x=input.nextInt();
Random y=new Random();
System.out.println("幸运数字是"+y.nextInt(10));
int a=x/100%10;
if (a==y.nextInt(10)){
System.out.println("恭喜你中奖了");
}else
{
System.out.println("很遗憾没中奖");
}
returnMain();
}
public static void tuicu() {
System.out.println("是否退出?");
Scanner input=new Scanner(System.in);
if(input.next().equalsIgnoreCase("Y")){
System.out.println("谢谢使用");
}else{
mainMenu();
}
}
}