2019.11.27 猜数字和条形码
作者:互联网
猜数字游戏代码
/**
* CaiShuZi.java
* com.lianxi
*
* Function: TODO
*
* ver date author
* ──────────────────────────────────
* 2019年11月27日 17671
*
* Copyright (c) 2019, TNT All Rights Reserved.
*/
package com.lianxi;
import java.util.Random;
import java.util.Scanner;
public class CaiShuZi {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
Random random=new Random();
int number=random.nextInt(100);
System.out.println("请输入一个数:");
int guessNumber=scanner.nextInt();
int count=0;
boolean flag=true;
while(flag) {
if (guessNumber<number) {
System.out.println("小了!");
guessNumber=scanner.nextInt();
count++;
}else if(guessNumber>number) {
System.out.println("大了!");
guessNumber=scanner.nextInt();
count++;
}
if (guessNumber==number) {
System.out.println("恭喜你猜对了"+",用了"+(count+1)+"次。");
flag=false;
}
}
}
}
13位条形码
/**
* LianXi17.java
* com.lianxi
*
* Function: TODO
*
* ver date author
* ──────────────────────────────────
* 2019年11月27日 17671
*
* Copyright (c) 2019, TNT All Rights Reserved.
*/
package com.lianxi;
import java.util.Scanner;
/**
* ClassName:LianXi17
* Function: TODO ADD FUNCTION
* Reason: TODO ADD REASON
*
* @author 17671
* @version
* @since Ver 1.1
* @Date 2019年11月27日 下午4:45:29
*
* @see
*/
public class LianXi17 {
public static void main(String[] args) {
// for (int i = 0; i < 4; i++) {
// for (int j = 0; j < 3-i; j++) {
// System.out.print(" ");
// }
// for (int j = 0; j < i+5; j++) {
// System.out.print("*");
// }
// for (int j = 0; j < i; j++) {
// System.out.print("*");
// }
// System.out.println();
// }
// for (int i = 1001; i < 10000; i++) {
// int a=i/100;
// int b=i%100;
// System.out.println(b);
// if (a*b==i) {
// System.out.println(i);
// }
// }
Scanner scanner=new Scanner(System.in);
int[] number=new int[12];
int x=0;
int y=0;
for (int i = 1; i <= 12; i++) {
number[i-1]=scanner.nextInt();
if (i%2!=0) {
x+=number[i-1];
}else if(i%2==0) {
y+=number[i-1];
}
}
int m=x+3*y;
int n=m%10;
int z=10-n;
if (z==10) {
z=0;
}
System.out.println(x+" "+y+" "+z);
for (int i = 0; i < number.length; i++) {
System.out.print(number[i]+" ");
if (i==number.length-1) {
System.out.print(z);
}
}
}
}
标签:条形码,27,int,System,number,++,2019.11,println,out 来源: https://www.cnblogs.com/aojie/p/11944610.html