首页
关于
留言
统计
友链
壁纸
影视
留言找电影
Search
1
java jdk17版本使用cglib报错问题解决
318 阅读
2
在Java中修复json数据,json格式不正确,如何在Java中修复不正确的json
114 阅读
3
Java实现双链表插入排序~渡星河全网首发
106 阅读
4
Java打印某年某月的日历~不调用函数
74 阅读
5
Java中判断是否是闰年
70 阅读
代码笔记
Java
css
Javascript
数据库
安卓开发
Java 功能实例
Java 封装
我的日常
影音分享
文案
恋爱问答
资源分享
电脑游戏
实用APP
登录
/
注册
Search
标签搜索
java
java作业
恋爱
动漫
3A大作
独行月球
电影分享
总之就是非常可爱
JavaScript
office
破解
mysql
vue
java打包
跨域
tomcat解决乱码
bug解决
tomcat
vscode
渡星河
累计撰写
94
篇文章
累计收到
30
条评论
首页
栏目
代码笔记
Java
css
Javascript
数据库
安卓开发
Java 功能实例
Java 封装
我的日常
影音分享
文案
恋爱问答
资源分享
电脑游戏
实用APP
页面
关于
留言
统计
友链
壁纸
影视
留言找电影
搜索到
5
篇与
的结果
2022-12-09
Java基础测试2
Chapter 02循环结构{card-default label="考察内容" width="100%"}Key Point :1.while循环2.do while循环3.for循环4.obreak5.continue{/card-default}题目图片{tabs}{tabs-pane label="第一页"} {/tabs-pane}{tabs-pane label="第二页"}{/tabs-pane}{tabs-pane label="第三页"}{/tabs-pane}{/tabs}一public class Method { public static void main(String[] args) { int sum = 0; for (int i = 0; i <=100; i++) { sum+=i; } System.out.println(sum); } }二public class Method { public static void main(String[] args) { int sum = 0; for (int i = 1; i <100; i+=2) { sum+=i; } System.out.println(sum); } }三public class Method { public static void main(String[] args) { int j=0,sum1=0; while (j<=100){ sum1+=j; j++; } System.out.println(sum1); int sum = 0; int i=1; do { sum+=i; i+=2; }while (i<100); System.out.println(sum); } } 四 import java.util.Scanner; public class Method { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("输入一个小于10的整数"); int n = sc.nextInt(); int sum = 1; if (n>9)return; for (int i =1;i<=n;i++)sum*=i; System.out.println(n+"的阶乘为:"+sum); } }五public class Method { public static void main(String[] args) { int sum = 0; for (int i = 1; i <=100;i++ ) { if (i%3==0&&i%5!=0) sum+=i; } System.out.println(sum); } }六public class Method { public static void main(String[] args) { for (int x = 0; x < 20; x++) { for (int y = 0; y < 33; y++) { int z = 100 - x - y; if ((z % 3 == 0) && (x * 5 + y * 3 + z / 3 == 100))System.out.println("公鸡:"+x+" 母鸡:"+y+" 小鸡:"+z); } } } } 七public class Method { public static void main(String[] args) { for (int x = 0; x < 8; x++) { for (int y = 0; y < 12; y++) { int z = 36 - x - y; if ((z % 3 == 0) && (x * 4 + y * 3 + z / 2 == 36))System.out.println("男:"+x+" 女:"+y+" 小孩:"+z); } } } } 八public class Method { public static void main(String[] args) { for (int x = 1000; x < 10000; x++) { int ge=x%10; int shi=x/10%10; int bai=x/100%10; int qian=x/1000; int i = (qian * 10 + bai) + (shi * 10 + ge); if(x== i * i)System.out.println(x); } } }九import java.util.Scanner; public class Method { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("输入n"); int n = sc.nextInt(); for (int i = 1 ;i<=n; i++){ for (int j = n; j > i; j--) { System.out.print(" "); } for (int j = 0; j < (2*i)-1; j++) { System.out.print("*"); } System.out.println(""); } } } 十public class Method { public static void main(String[] args) { for(int i = 1;i<10;i++){ for(int j = 1;j<=i;j++){ if(j==3&&i==3||j==3&&i==4){ System.out.print(" "+j+"×"+i+"="+(i*j)+" "); }else{ System.out.print(j+"×"+i+"="+(i*j)+" "); } } System.out.println(); } } }十一public class Method { public static void main(String[] args) { int a,b,c; for(int i = 100;i<999;i++){ a = i/100; b = i%100/10; c = i%100%10; if (a*a*a+b*b*b+c*c*c==i) System.out.println(i); } } }
2022年12月09日
13 阅读
0 评论
1 点赞
2022-12-07
今日Java作业
作业题目1、00101010 | 00010111语句的执行结果为2、00101010 & 00010111语句的执行结果为3、37.2%10的运算结果为4、定义一个华氏度,转换成相应的摄氏度输出。(转换规则:摄氏度=5/9*(华氏度–32))5、定义一个三位整数,分别输出其个位、十位和百位6、定义一个四位整数,分别输出其个位、十位和百位、千位7、完成打印输出Java所有基本数据类型及所占字节数,格式如效果图。类型所占字节取值范围占多少位byte1字节-2^7~2个7-18位short 2字节-2个15~2个15-116位int4字节-2个31~2个31-132位8、从键盘输入三角形的底和高,并输出三角形的面积。9、从控制台输入学员王浩3门课程(Java、SQL、Php)成绩,编写程序实现(1) Java课和SQL课的分数之差(2)3门课的平均分10、定义两个变量int a = 10 int b = 20 ,交换两个变量的值11、选做题某个公司采用公用电话传递数据,数据是四位的整数,在传递过程中是加密的,加密规则如下:每位数字都加上3然后除以10的余数代替该数字,再将第一位和第四位交换,第二位和第三位交换。要求:键盘上输入四位号码,求加密后的号码为多少?答案题目简单不做思路分析,思路分析请搜索上一次的Java作业import java.util.Scanner; public class work { public static void main(String[] args) { System.out.println(00101010 | 00010111); //37449 System.out.println(00101010 & 00010111); //8 System.out.println(37.2%10); //7.200000000000003 Scanner sc = new Scanner(System.in); System.out.println("输入摄氏度"); float c = sc.nextFloat(); float jg = c*9/5+32; System.out.println("温度转换结果为:"+jg); //-------------------------------- tree(); //-------------------------------- four(); System.out.println("类型 所占字节 取值范围 占多少位"); System.out.println("byte 1字节 -2^7~2^7-1 8位"); System.out.println("short 2字节 -2^15~2^15-1 16位"); System.out.println("int 4字节 -2^31~2^31-1 32位"); //--------------- five(); sex(); //交换 int a = 10; int b = 20; int tmp = a; a=b;b=tmp; //最后 seven(); } public static void tree() { Scanner sc = new Scanner(System.in); System.out.println("输入一个三位数"); int num = sc.nextInt(); if (num>99 && num <1000){ int bai = num/100; int shi = num%100/10; int ge = num%100%10; System.out.println("百分位:"+bai+" 十分位:"+shi+" 个位:"+ge); }else { System.out.println("输入的不是一个三位整数"); } } //第四个 public static void four() { Scanner sc = new Scanner(System.in); System.out.println("输入一个四位数"); int num = sc.nextInt(); if (num>999 && num <10000){ int qian = num/1000; int bai = num%1000/100; int shi = num%1000%100/10; int ge = num%1000%100%10; System.out.println("千分位:"+qian+" 百分位:"+bai+" 十分位:"+shi+" 个位:"+ge); }else { System.out.println("输入的不是一个四位整数"); } } public static void five() { Scanner sc = new Scanner(System.in); System.out.println("输入高度"); int h = sc.nextInt(); System.out.println("输入底"); int sd = sc.nextInt(); System.out.println("梯形的面积为:"+(sd*h/2)); } public static void sex(){ Scanner sc = new Scanner(System.in); System.out.println("输入java成绩"); int Java = sc.nextInt(); System.out.println("输入SQL成绩"); int Sql = sc.nextInt(); System.out.println("输入PHP成绩"); int Php = sc.nextInt(); System.out.println("--------王浩同学的成绩--------"); System.out.println("Java:"+Java); System.out.println("SQL:"+Sql); System.out.println("PHP:"+Php); System.out.println("平均分为:"+((Java+Sql+Php)/3)); } public static void seven(){ Scanner sc = new Scanner(System.in); System.out.println("四位号码"); int num = sc.nextInt(); if (num>999 && num <10000){ int qian = (num/1000+3)%10; int bai = (num%1000/100+3)%10; int shi = (num%1000%100/10+3)%10; int ge = (num%1000%100%10+3)%10; qian = ge; ge = tmp; tmp = bai; bai=shi; shi=tmp; System.out.println("加密后:"+qian+bai+shi+ge); }else { System.out.println("输入的不是一个四位整数"); } } } 运行结果太多了懒得截图
2022年12月07日
15 阅读
0 评论
2 点赞
2022-11-25
java 使用栈进行表达式计算
思路图{mtitle title="我的代码"/}package test; public class Work { public static void main(String[] args) { Chars chars = new Chars(); Number num = new Number(); String data = "( 5 +( (2 + 3 )* (4*5)))"; data = data.replace(" ", ""); char[] outchar = data.toCharArray(); int i = 0; do { switch (outchar[i]){ case '(': break; case '+': case '*': case '-': case '/': chars.push(outchar[i]); break; case ')': int one = num.pop(); int two = num.pop(); switch (chars.pop()) { case '+' -> num.push(one + two); case '-' -> num.push(one - two); case '*' -> num.push(one * two); case '/' -> num.push(one / two); default -> System.out.println("符号错误"); } break; default: String str = String.valueOf(outchar[i]); int nums = Integer.parseInt(str); num.push(nums); break; } i++; }while (i<outchar.length); System.out.println("结果是"+num.pop()); } } class Chars { char[] chararr = new char[10]; int top = -1; public void push(char val){ int size = chararr.length; if(top+1==size){ char[] temp = new char[size]; int tempTop = -1; while (top > -1){ tempTop++; temp[tempTop]=pop(); } chararr = temp; top = tempTop; tempTop = -1; char[] newArr = new char[size*2]; while (top > -1){ tempTop++; newArr[tempTop]=pop(); } top = tempTop; chararr = newArr; } top++; chararr[top]=val; } public char pop(){ char res =chararr[top]; top--; return res; } } class Number{ int[] numarr = new int[10]; int top = -1; public void push(int val){ int size = numarr.length; if(top+1==size){ int[] temp = new int[size]; int tempTop = -1; while (top > -1){ tempTop++; temp[tempTop]=pop(); } numarr = temp; top = tempTop; tempTop = -1; int[] newArr = new int[size*2]; while (top > -1){ tempTop++; newArr[tempTop]=pop(); } top = tempTop; numarr = newArr; } top++; numarr[top]=val; } public int pop(){ int res = numarr[top]; top--; return res; } public int top(){ if (top == -1) return 0; return numarr[top]; } }{mtitle title="鹏哥的代码"/}//计算表达式 public class Caculate { public static void main(String[] args) { //创建存储操作符和操作数栈对象 Ops ops = new Ops(); Val vals = new Val(); //定义测试数据,规定:本实例只支持个位数的整数加减乘除 String data = "( 5 +( (2 + 3 )* (4*5)))"; //使用字符串String类的replace()方法,去掉字符串中的空格。 data = data.replace(" ", ""); //把字符串转换成字符数组,只需要调用字符串的toCharArray()方法即可。 char[] chars = data.toCharArray(); //遍历字符数组获取单个的字符。 for(int x = 0; x < chars.length; x++) { char s = chars[x];//拿到单个字符 //逐个判断当前字符是操作符还是操作数 //如果是操作符就压入操作符栈中。 if(s == '(');//我们规定计算式忽略左括号 else if (s == '+') ops.push(s); else if (s == '-') ops.push(s); else if (s == '*') ops.push(s); else if (s == '/') ops.push(s); else if (s == ')') { //如果遇到右括号,此时我们需要从操作符栈中取出一个操作符, //从操作数栈中取出两个操作数,然后计算结果并再次压入操作数栈中 char op = ops.pop(); int v = vals.pop(); //判断取出来的操作符op属于哪一种运算符 if(op == '+') v = vals.pop() + v; else if(op == '-') v = vals.pop() - v; else if(op == '*') v = vals.pop() * v; else if(op == '/') v = vals.pop() / v; //把计算完成之后还需要把数据再次压入操作数栈中 vals.push(v); } else { //把字符转成字符串 String str = String.valueOf(s); //把字符串数据转成整数数据 int vl = Integer.parseInt(str); //如果属于操作数就压入操作数栈中 vals.push(vl); } } System.out.println(vals.pop()); System.out.println(vals.pop()); System.out.println(ops.pop()); } } //存放操作符的栈 class Ops { //因为我们的栈是基于数组来实现的,因此我们需要先创建数组。 static char[] c = new char[10]; //栈的属性top static int top = -1; //入栈方法 public static void push(char ch) { if(top < c.length) { c[++top] = ch; } } //出栈方法 public static char pop() { if(top > -1) return c[top--]; return '!'; } } //存放操作数的栈 class Val { //因为我们的栈是基于数组来实现的,因此我们需要先创建数组。 static int[] v = new int[10]; //栈的属性top static int top = -1; //入栈方法 public static void push(int value) { if(top < v.length) v[++top] = value; } //出栈方法 public static int pop() { if(top > -1) return v[top--]; return -2147483648; } }{alert type="info"}打印出结果为 105{/alert}
2022年11月25日
21 阅读
0 评论
0 点赞
2022-11-11
Java打印某年某月的日历~不调用函数
这个题目说真的有点难搞哦,又不调用函数,思路想到自闭,很不幸我还是做出来了{card-describe title="做题思路"}第一步肯定是先获取键盘输入的年月计算1900年到你需要打印年的天数(为什么是1900年百度哦)计算一月到你打印的那个月的天数计算打印的那个月有多少天用总天数去和7去余数,用于日历前面空格,为什么与7取,因为我们还要判断是星期几然后使用for循环打印{/card-describe}我们这边打印一个2022年5月的日历,先给大家看看百度的日历当然我们的代码是做不出这样的,我们看看代码怎么写的import java.util.Scanner; public class Work4 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("请输入年份"); int year = sc.nextInt(); System.out.println("请输入月份"); int month = sc.nextInt(); int total=0; System.out.println("---------"+year+"年"+month+"月---------\n"); System.out.println("一\t二\t三\t四\t五\t六\t日"); //计算1900年到任一年份一月一日是星期几 //注意比如year是2022年计算到的是2021年最后的天数 for(int i =1900;i<year;i++){ //判断是否是闰年 if((i%4)==0 && (i%100) !=0 || (i%400)==0){ total+=366; }else { total+=365; } } //如果当年是闰年 boolean pdyear = (year % 4) == 0 && (year % 100) != 0 || (year % 400) == 0; //计算一月到你需要的月份的天数有多少 for(int i = 1; i<month; i++){ //小月就是30 if(i==4||i==6||i==9||i==11){ total+=30; }else if(i==2){ //二月这里需要区分是什么年,上面表达式计算布尔值 if(pdyear){ total+=29; }else{ total+=28; } //否则就是大月 }else{ total+=31; } } //计算出那个月有多少天 int day; if(month==4||month==6||month==9||month==11){ day=30; }else if(month==2){ if(pdyear){ day=29; }else{ day=28; } }else{ day=31; } //计算出那个月份的1号是星期几 int week = (total+1)%7; //计算需要空出的空间 int tab; if (week == 0) { tab=6; }else { tab = week-1; } for(int t = 1;t<=tab;t++){ System.out.print("\t"); } for(int d = 1;d<=day;d++){ if((total+d)%7==0){ System.out.println(d); }else{ System.out.print(d+"\t"); } } } } 我们看一下运行结果,不会的评论,这边邮件提醒回复快
2022年11月11日
74 阅读
0 评论
1 点赞
2022-11-08
Java基础题小试牛刀
1. 键盘上输入一个摄氏温度,然后把摄氏温度转换成华氏度温度输出。{card-describe title="摄氏度转换华氏度"}摄氏温度c ,将其转化为华氏温度f ,转换公式为:f=c*9/5+32{/card-describe}2. 键盘输入上底,下底,高,然后求梯形的面积。{card-describe title="梯形面积公式"}面积s,高为h s=(上底+下底)×高÷2{/card-describe}3. 输入一个三位数,分别获取其中个位,十位,百位。{card-describe title="做题思路"}因为int只保留整数,我们可以通过三位数去除以100来获得百分位十分位我们需要获得需要先通过除以100来取余在进行整除10来获得个为直接取100的余数在去10的余数就好了{/card-describe}4. 输入一个四位数,分别获取其中个位,十位,百位,千位。{card-describe title="做题思路"}只要会了上面的就会这个,思考一下吧,可以看看我下面代码怎么完成的哦{/card-describe}//导入包,前期讲过了 import java.util.Scanner; //创建一个类,记得文件需要和类名一致 public class Work { //第一个题目代码 public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("输入摄氏度"); float c = sc.nextFloat(); float jg = c*9/5+32; System.out.println("温度转换结果为:"+jg); System.out.println("计算梯形的面积"); //调用第二个题目代码运行,后面一样的 two(); } //第二个题目代码 public static void two() { Scanner sc = new Scanner(System.in); System.out.println("输入高度"); int h = sc.nextInt(); System.out.println("输入上底"); int sd = sc.nextInt(); System.out.println("输入下底"); int xd = sc.nextInt(); System.out.println("梯形的面积为:"+((sd+xd)*h/2)); System.out.println("计算三位数的个十百"); tree(); } //第三个 public static void tree() { Scanner sc = new Scanner(System.in); System.out.println("输入一个三位数"); int num = sc.nextInt(); if (num>99 && num <1000){ int bai = num/100; int shi = num%100/10; int ge = num%100%10; System.out.println("百分位:"+bai+" 十分位:"+shi+" 个位:"+ge); }else { System.out.println("输入的不是一个三位整数"); } System.out.println("计算四位数的个十百千"); four(); } //第四个 public static void four() { Scanner sc = new Scanner(System.in); System.out.println("输入一个四位数"); int num = sc.nextInt(); if (num>999 && num <10000){ int qian = num/1000; int bai = num%1000/100; int shi = num%1000%100/10; int ge = num%1000%100%10; System.out.println("千分位:"+qian+" 百分位:"+bai+" 十分位:"+shi+" 个位:"+ge); }else { System.out.println("输入的不是一个四位整数"); } System.out.println("计算四位数的个十百千"); } } //心中无女人代码自然神!!!!!!!
2022年11月08日
55 阅读
1 评论
1 点赞