标签:-- 游戏 void static can public 错误 乘法表 代码
public class 输出100以内的质数 {
public static void main(String[] args) {
int a,b;
oute: for (a =2;a<100;a++){
for (b =2;b<a/2;b++){
if (a%b==0)
continue oute;
}
System.out.print(a+" ");
}
public class 输出1000以内可以被5整除的数 {
public static void main(String[] args) {
for (int i = 1; i <= 1000; i++) {
if (i%5==0){
System.out.print(i+"\t");
}
if (i%15==0){
System.out.println();
}
}
}
}
import java.util.Scanner;
public class 判断输入的字符串 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入密码:");
String pwd = scanner.nextLine();
if (pwd.equals("admin123")){
System.out.println("密码正确!");
}else {
System.out.println("密码错误!");
}
scanner.close();
}
}
public class 打印三角形 {
public static void main(String[] args) {
for (int i = 1; i <=5; i++) {
for (int j =5;j>=i;j--){
System.out.print(" ");
}
for (int j =1; j<=i;j++){
System.out.print("*");
}
for (int j =1; j<i;j++){
System.out.print("*");
}
System.out.println();
}
}
}
public class 九九乘法表 {
public static void main(String[] args) {
for (int i = 1; i <=9 ; i++) {
for (int j = 1; j <=i ; j++) {
System.out.print(i+"*"+j+"="+(i*j)+"\t");
if (i==j){
System.out.println();
}
}
}
}
}
import java.util.Scanner;
public class 猜数字游戏 {
public static void main(String[] args) {
System.out.print("输入1~100的整数:");
int i = (int)(99*Math.random())+1;
Scanner scanner =new Scanner(System.in);
int j =scanner.nextInt();
while (i!=j){
if (i < j) {
System.out.println("猜大了");
} else {
if (i > j) {
System.out.println("猜小了");
}
}
System.out.print("再猜:");
j =scanner.nextInt();
}
System.out.println("猜对了!!");
}
}
标签:-- 游戏 void static can public 错误 乘法表 代码
原文地址:https://www.cnblogs.com/ice-point/p/12907646.html