public class Practice4_2_01 { public static void main(String[] args) { int i ; int ge; int shi; int bai ; for ( i = 100; i < 1000; i++) { ge = i%10; shi = i/10%10; bai = i/100; if(ge*ge*ge+shi*shi*shi+bai*bai*bai==i){ System.out.println(); } } }
package practice4_2; /* * 输出三角形 */ public class Practice4_2_02 { //正直角三角形 public static void main(String[] args) { for (int i = 1; i < 7; i++) { for (int j = 1; j <= i; j++) { System.out.print(j); } System.out.println(); } //倒直角三角形 for (int i = 6; i >0; i--) { for (int j = i; j > 0; j--) { System.out.print(j); } System.out.println(); } } }
package practice4_2; import java.util.Scanner; //输入年月日判断是今年第几天 public class Practice4_2_03 { public static void main(String[] args) { Scanner sca= new Scanner(System.in); System.out.println("输入年份"); int year = sca.nextInt(); System.out.println("输入月份"); int month = sca.nextInt(); System.out.println("输入日期"); int days=0; int day = sca.nextInt(); if ((year/4==0&&year/100!=0)||year/400==0) { for (int i = 0; i < month; i++) { if (i<4) { days = day+i*30+i/2+i%2; }else{ days = day+i*30+i/2+i%2-2; } } System.out.println("今天是今年的:"+days+"天"); }else{ for (int i = 0; i < month; i++) { if (i<4) { days = day+i*30+i/2+i%2; }else{ days = day+i*30+i/2+i%2-1; } } System.out.println("今天是今年的:"+days+"天"); } } }
package practice4_2; import java.util.Scanner; /* * 输入四位数之后翻转该数 */ public class Practice4_2_04 { public static void main(String[] args) { Scanner sca= new Scanner(System.in); System.out.println("输入一个四位数"); int num = sca.nextInt(); int ge,shi,bai,qian; if (num<1000||num>10000) { System.out.println("您输入的有误"); }else{ qian = num/1000; bai = num/100%10; shi =num/10%10; ge= num%10; System.out.print(ge); System.out.print(shi); System.out.print(bai); System.out.print(qian); } } }