java入门

第一个java程序,纪念一下。。。。

import java.util.Scanner;
02.  
03. public class Main {
04. public static void main(String[] args) {
05. Scanner input = new Scanner(System.in);
06. int numberA = input.nextInt();
07. int numberB = input.nextInt();
08. System.out.print(numberA+numberB);
09. }
10. }


01. import java.util.Scanner;
02.  
03. public class Main {
04. public static void main(String[] args) {
05. Scanner input = new Scanner(System.in);
06.  
07. int number1 = input.nextInt();
08. int number2 = input.nextInt();
09. int number3 = input.nextInt();
10. int temp;
11.  
12.  
13. if(number1 > number2)
14. {temp = number1; number1 = number2; number2 = temp;}
15. if(number1 > number3)
16. {temp = number1; number1 = number3; number3 = temp;}
17. if(number2 > number3)
18. {temp = number2; number2 = number3; number3 = temp;}
19.  
20.  
21. System.out.println(number1 + " " + number2 + " " + number3);
22. }
23. }


01. import java.util.Scanner;
02.  
03. public class Main {
04. public static void main(String[] args) {
05. Scanner input = new Scanner(System.in);
06.  
07.  
08. int numberFir;
09. int numberSec;
10. int numberThid;
11. int shuiXianHua;
12. int total;
13.  
14.  
15. while(true){
16.  
17. shuiXianHua = input.nextInt();
18. if(shuiXianHua == 0)
19. break;
20.  
21.  
22. numberFir = shuiXianHua % 10;
23. numberSec = shuiXianHua / 10 % 10;
24. numberThid = shuiXianHua / 100;
25.  
26. total = numberFir * numberFir * numberFir +
27. numberSec * numberSec * numberSec + numberThid *
28. numberThid * numberThid;
29.  
30. if(total == shuiXianHua)
31. System.out.println("Yes");
32. else
33. System.out.println("No");
34. }
35.  
36. }
37. }

学过c之后真心觉得学起来java有一点还可以,目前为止还有点自信,希望能坚持下去

posted @   wojiaohuangyu  阅读(5)  评论(0编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 终于写完轮子一部分:tcp代理 了,记录一下
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
点击右上角即可分享
微信分享提示