栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

2021-07-22 Java练习题,kafka数据存储原理

2021-07-22 Java练习题,kafka数据存储原理

public static void topic() {

System.out.println(“请输入你想运行题目的序号:”);

Scanner s = new Scanner(System.in);

int t = s.nextInt();

switch (t) {

case 1:

topic01();

break;

case 2:

topic02();

break;

case 3:

topic03();

break;

case 4:

topic04();

break;

case 5:

topic05();

break;

case 6:

topic06();

break;

case 7:

topic07();

break;

case 8:

topic08();

break;

case 801:

topic0801();

break;

}

}

public static void topic01() {

int sum = 0;

for (int i = 1; i <= 100; i++) {

if (i % 7 == 0) sum += i;

}

System.out.println(“1到100能被7整除的数字和为” + sum);

}

public static void topic02() {

System.out.println(“请输入年份:”);

Scanner s = new Scanner(System.in);

int year = s.nextInt();

System.out.println(“请输入月份:”);

int month = s.nextInt();

System.out.println(“请输入日份:”);

int day = s.nextInt();

int sum = 0;

for (int i = 0; i < month; i++) {

switch (i) {

case 1:

case 3:

case 5:

case 7:

case 8:

case 10:

case 12:

sum += 31;

break;

case 4:

case 6:

case 9:

case 11:

sum += 30;

break;

case 2:

if (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)) {

sum += 29;

} else {

sum += 28;

}

}

}

sum += day;

System.out.println(“这一天是这一年的第” + sum + “天”);

}

public static void topic03() {

double molecular = -4;

double denominator = 1;

double PI = 0;

int frequency = -1;

while (PI >= 3.1415927 || PI <= 3.1415926) {

molecular = -molecular;

PI += molecular / denominator;

denominator += 2;

frequency++;

}

System.out.println(“一共需要运行” + frequency + “次”);

}

public static void topic04() {

int height = 7;

int day = 0;

while (height != 0) {

day++;

height -= 3;

if (height != 0) {

height += 2;

}

}

System.out.println(day);

}

public static void topic05() {

int a = 0;

int b = 0;

int c = 0;

for (int i = 1; i <= 10; i++) {

System.out.println(“请输入第” + i + “个字符”);

Scanner s = new Scanner(System.in);

String str = s.nextLine();

Pattern p1 = compile("[a-zA-Z]");

Pattern p2 = compile("[0-9]");

Matcher m1 = p1.matcher(str);

Matcher m2 = p2.matcher(str);

if (m1.find()) {

a++;

} else if (m2.find()) {

b++;

} else {

c++;

}

}

System.out.println(“你输入了” + a + “个字母、” + b + “个数字、” + c + “个其他字符”);

}

public static void topic06() {

int i = 0;

int j = 0;

for (i = 1; i <= 9; i++) {

for (j = 1; j <= i; j++) {

//print是不换行输出;而println是换行输出。该处使用print输出

Sy

【一线大厂Java面试题解析+核心总结学习笔记+最新架构讲解视频+实战项目源码讲义】

浏览器打开:qq.cn.hn/FTf 免费领取

stem.out.println(i + “*” + j + “=” + i * j);

}

}

}

public static void topic07() {

System.out.println(“请输入你要求的最大阶乘:”);

Scanner s = new Scanner(System.in);

int max = s.nextInt();

long sum = 0;

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/389291.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号