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有一点还可以,目前为止还有点自信,希望能坚持下去

你可能感兴趣的:(java入门)