public class Prog11{ public static void main(String[] args){ int count = 0; int n = 0; for(int i=1;i<5;i++){ for(int j=1;j<5;j++){ if(j==i) continue; for(int k=1;k<5;k++){ if(k!=i && k!=j){ n = i*100+j*10+k; System.out.print(n+" "); if((++count)%5==0) System.out.println(); } } } } System.out.println(); System.out.println("符合条件的数共:"+count+"个"); } } |
import java.io.*; public class Prog12{ [size=10.0000pt] public static void main(String[] args){ [size=10.0000pt] [size=10.0000pt] System.out.print("请输入当前利润[size=10.0000pt]:"); [size=10.0000pt] [size=10.0000pt] long profit = Long.parseLong(key_Input()); [size=10.0000pt] [size=10.0000pt] System.out.println("应发奖金[size=10.0000pt]:"+bonus(profit)); [size=10.0000pt] [size=10.0000pt]} [size=10.0000pt] //接受从键盘输入的内容 [size=10.0000pt] private static String key_Input(){ [size=10.0000pt] [size=10.0000pt] String str = null; [size=10.0000pt] [size=10.0000pt] BufferedReader bufIn = new BufferedReader(new InputStreamReader(System.in)); [size=10.0000pt] [size=10.0000pt] try{ [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] str = bufIn.readLine(); [size=10.0000pt] [size=10.0000pt] }catch(IOException e){ [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] e.printStackTrace(); [size=10.0000pt] [size=10.0000pt] }finally{ [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] try{ [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] bufIn.close(); [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] }catch(IOException e){ [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] e.printStackTrace(); [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] [size=10.0000pt]} [size=10.0000pt] [size=10.0000pt] [size=10.0000pt]} [size=10.0000pt] [size=10.0000pt] return str; [size=10.0000pt] [size=10.0000pt]} [size=10.0000pt] //计算奖金 [size=10.0000pt] private static long bonus(long profit){ [size=10.0000pt] [size=10.0000pt] long prize = 0; [size=10.0000pt] [size=10.0000pt] long profit_sub = profit; [size=10.0000pt] [size=10.0000pt] if(profit>1000000){ [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] profit = profit_sub-1000000; [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] profit_sub = 1000000; [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] prize += profit*0.01; [size=10.0000pt] [size=10.0000pt] [size=10.0000pt]} [size=10.0000pt] [size=10.0000pt] if(profit>600000){ [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] profit = profit_sub-600000; [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] profit_sub = 600000; [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] prize += profit*0.015; [size=10.0000pt] [size=10.0000pt] [size=10.0000pt]} [size=10.0000pt] [size=10.0000pt] if(profit>400000){ [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] profit = profit_sub-400000; [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] profit_sub = 400000; [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] prize += profit*0.03; [size=10.0000pt] [size=10.0000pt] [size=10.0000pt]} [size=10.0000pt] [size=10.0000pt] if(profit>200000){ [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] profit = profit_sub-200000; [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] profit_sub = 200000; [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] prize += prize*0.05; [size=10.0000pt] [size=10.0000pt] [size=10.0000pt]} [size=10.0000pt] [size=10.0000pt] if(profit>100000){ [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] profit = profit_sub-100000; [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] profit_sub = 100000; [size=10.0000pt] [size=10.0000pt] [size=10.0000pt] prize += profit*0.075; [size=10.0000pt] [size=10.0000pt] [size=10.0000pt]} [size=10.0000pt] [size=10.0000pt] prize += profit_sub*0.1; [size=10.0000pt] [size=10.0000pt] return prize; [size=10.0000pt] [size=10.0000pt]} [size=10.0000pt]} |
public class Prog13{ public static void main(String[] args){ int n=0; for(int i=0;i<100001;i++){ if(isCompSqrt(i+100) && isCompSqrt(i+268)){ n = i; break; } } System.out.println("所求的数是:"+n); } //判断完全平方数 private static boolean isCompSqrt(int n){ boolean isComp = false; for(int i=1;i<Math.sqrt(n)+1;i++){ if(n==Math.pow(i,2)){ isComp = true; break; } } return isComp; } } |
import java.util.Scanner; public class Prog14{ public static void main(String[] args){ Scanner scan = new Scanner(System.in).useDelimiter("\\D");//匹配非数字 System.out.print("请输入当前日期(年-月-日):"); int year = scan.nextInt(); int month = scan.nextInt(); int date = scan.nextInt(); scan.close(); System.out.println("今天是"+year+"年的第"+analysis(year,month,date)+"天"); } //判断天数 private static int analysis(int year, int month, int date){ int n = 0; int[] month_date = new int[] {0,31,28,31,30,31,30,31,31,30,31,30}; if((year%400)==0 || ((year%4)==0)&&((year%100)!=0)) month_date[2] = 29; for(int i=0;i<month;i++) n += month_date; return n+date; } } |
import java.util.Scanner; public class Prog15{ public static void main(String[] args){ Scanner scan = new Scanner(System.in).useDelimiter("\\D"); System.out.print("请输入三个数:"); int x = scan.nextInt(); int y = scan.nextInt(); int z = scan.nextInt(); scan.close(); System.out.println("排序结果:"+sort(x,y,z)); } //比较两个数的大小 private static String sort(int x,int y,int z){ String s = null; if(x>y){ int t = x; x = y; y = t; } if(x>z){ int t = x; x = z; z = t; } if(y>z){ int t = z; z = y; y = t; } s = x+" "+y+" "+z; return s; } } |
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) | 黑马程序员IT技术论坛 X3.2 |