Topic: There are 1, 2, 3, 4 digits. How many different and non-repetitive three digits can be formed? How many are they?
1. Program analysis: The numbers that can be filled in 100, 10 and 4 bits are 1, 2, 3 and 4. After all the permutations are made up, the permutations that do not satisfy the conditions are removed.
[Procedure 12]
Topic: The bonus paid by enterprises is based on profit. When the profit is less than or equal to 100,000 yuan, the bonus can be increased by 10%; when the profit is higher than 100,000 yuan or less than 200,000 yuan, the part less than 100,000 yuan is deducted by 10%, and the part higher than 100,000 yuan is deducted by 75%; between 200,000 and 400,000 yuan, the part higher than 200,000 yuan is deducted by 5%; between 400,000 and 600,000 yuan, the part higher than 400,000 yuan is deducted by 3%; between 600,000 and 1,000 yuan is deducted by more than 600,000 yuan. When the percentage is 1.5%, when it is higher than 1 million yuan, the proportion of more than 1 million yuan is deducted by 1%. The profit I of the month is input from the keyboard, and the total amount of bonus should be paid?
1. Program analysis: Please use the number axis to demarcate and locate. Note that bonuses need to be defined as growth shaping.
[Program 13] FindNumber.java
Topic: An integer, it is a complete square after adding 100, and 168 is a complete square. What is the number, please?
1. Procedure analysis: Judging within 100,000, first add 100 to the number and then start the prescription, then add 268 to the number and then start the prescription. If the result after the prescription meets the following conditions, it is the result. See the specific analysis:
[Procedure 14]
Title: Enter a date of a certain year, a certain month, and determine the date of the year?
1. Procedure analysis: Take March 5 as an example, we should add up the first two months, then add five days, which is the first day of the year. Under special circumstances, when the leap year and the input month is more than three, we need to consider one more day.
[Procedure 15]
Topic: Input three integers x,y,z. Please output these three integers from small to large.
1. Program analysis: We try to put the smallest number on X. First, we compare x with y. If x > y, we exchange the values of X and y. Then we compare x with Z. If x > z, we exchange the values of X and z, so that x can be minimized.
[Procedure 16]
Topic: Output 9*9 recipes.
1. Procedure analysis: Consideration of rows and columns, a total of 9 rows and 9 columns, i control row, j control column.
[Program 17] MonkeyEatPeach.java
Title: The problem of eating peaches for monkeys: On the first day, the monkeys picked several peaches and ate half of them immediately. They were not addicted to it. They ate half of the remaining peaches the next morning and one more. Every morning I ate half and one of the rest of the previous day. When I wanted to eat again on the 10th morning, I saw that there was only one peach left. Seek how many you picked on the first day.
1. Procedure analysis: Reverse thinking is used to infer from the back to the front.
[Procedure 18]
Topic: Two table tennis teams compete, each with three players. The first team is a, B and c, and the second team is x, y and Z. The competition list has been decided by lot. The players were asked about the list of matches. A says he's not compared with x, C says he's not compared with x,z. Please program to find out the list of the three teams.
1. Program analysis: the method of judging prime number: remove 2 to sqrt with one number, if it can be divided, it shows that the number is not prime, otherwise it is prime.
[Procedure 19]
Title: Print out the following pattern (diamond)
*
***
*****
*******
*****
***
*
1. Program analysis: First, divide the graphics into two parts, one rule in the first four rows and one rule in the last three rows, using double for loop, the first control row and the second control column.
[Procedure 20]
Title: There is a fraction sequence: 2/1, 3/2, 5/3, 8/5, 13/8, 21/13.. Find out the sum of the top 20 items of this sequence.
1. Programming analysis: Please grasp the law of variation of molecules and denominators.
package javaimprove011; /* * [Program 11] TestTN.java Topic: There are 1, 2, 3, 4 digits. How many different and non-repetitive three digits can be formed? How many are they? 1.Procedure analysis: I don't quite understand this topic, so long and simple to my understanding with 1234 these four digits constitute three digits which do not repeat each other and output, if there is a wrong, welcome to correct. */ public class Duplicate { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub for(int i=1;i<5;i++) for(int j=1;j<5;j++) { for(int k=1;k<5;k++) { if(i!=j&&j!=k&&i!=k) System.out.printf("%d\t", 100*k+10*j+i); } System.out.println(); } } }
package javaimprove012; import java.util.Scanner; /* * [Program 12] MoneyAward.java Topic: The bonus paid by enterprises is based on profit. When profit (I) is less than or equal to 100,000 yuan, the bonus can be increased by 10%. When the profit is higher than 100,000 yuan and lower than 200,000 yuan, the part less than 100,000 yuan will be deducted by 10% and the part higher than 100,000 yuan will be deducted by 7.5%. 20 Between 10,000 and 400,000 yuan, a 5% deduction can be made for the portion above 200,000 yuan. 40 Between 10,000 and 600,000,000,000,000,000 yuan is more than 400,000 yuan, which can be deducted by 3%. 60 Between 10,000 and 1,000,000 yuan, the portion over 600,000 yuan can be deducted by 1.5%, while the portion over 1,000,000 yuan can be deducted by 1%. Input the profit I from the keyboard for the current month, and ask for the total bonus payable? Problem analysis: The problem itself is very simple, and there are several ways to achieve it. */ public class Award { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Please enter the current month's profit(Ten thousand yuan): "); Scanner in=new Scanner(System.in); int profit=in.nextInt(); System.out.printf("The bonus payable is:%f Ten thousand yuan", profit<=10? (profit*0.1):(profit<=20?10*0.1+(profit-10)*0.075: (profit<=40?10*0.1+10*0.075+(profit-20)*0.005: (profit<=60?10*0.1+10*0.075+20*0.005+(profit-40)*0.003: (profit<=100?10*0.1+10*0.075+20*0.005+20*0.003+(profit-60)*0.015:10*0.1+10*0.075+20*0.005+20*0.003+40*0.015+(profit-100)*0.01))))); } }
package javaimprove013; /* * Topic: An integer, it is a complete square after adding 100, and 168 is a complete square. What is the number, please? * Problem Analysis: One-by-one Positive Attempt */ public class FindSpecial { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub for(int n=1;n<100000000;n++) { if(Math.sqrt(n+100)%1==0&&Math.sqrt(n+100+168)%1==0) System.out.println(n); } } }
package javaimprove014; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.Scanner; /* * [Program 14) TestDay.java Title: Enter a date of a certain year, a certain month, and determine the date of the year? Problem analysis: Java has calendar for processing dates, so the program is relatively simple. */ public class Day { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Please enter the date of your query (format: 2007 09 10):"); Scanner in=new Scanner(System.in); //SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Calendar calendar=Calendar.getInstance(); //Month starts at 0, so in order to get the exact time we need, we need to subtract one from here. int year=in.nextInt(); calendar.set(year,in.nextInt()-1,in.nextInt()); Date date=calendar.getTime(); calendar.set(year,00,00);//The year begins at 0 o'clock. Date begindate=calendar.getTime(); //Find the date difference between long day=(date.getTime()-begindate.getTime())/(24*60*60*1000); System.out.printf("This is the first year of the year.%d day\n",day); } }
package javaimprove015; import java.util.Arrays; import java.util.Scanner; /* * Topic: Input three integers x,y,z. Please output these three integers from small to large. * Problem analysis: There are sorting methods in Java that can be called directly, but you can also think about how you can achieve quick sorting. * There are several basic algorithms in the data structure. Of course, there are only three numbers, so there is nothing good or bad about them. */ public class Sort { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Please enter three integers:"); Scanner in=new Scanner(System.in); int[] array=new int[3]; array[0]=in.nextInt(); array[1]=in.nextInt(); array[2]=in.nextInt(); Arrays.sort(array);//Use arrays to sort directly. This is easier to use directly when data is scarce. System.out.printf("%d,%d,%d",array[0],array[1],array[2]); } }
package javaimprove016; /* * Topic: Output 9*9 recipes. */ public class MultiplicationTable { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub for(int i=1;i<10;i++) { for(int j=1;j<10;j++) System.out.printf("%d*%d=%2d ",j,i,i*j); System.out.println(); } } }
package javaimprove017; /* * Title: The problem of monkeys eating peaches: On the first day, the monkeys picked several peaches and ate half of them immediately. They were not addicted to another one. * The next morning he ate half of the remaining peaches and one more. * Every morning I ate half and one of the rest of the previous day. * When I wanted to eat again on the 10th morning, I saw that there was only one peach left. * Seek how many you picked on the first day. * Problem analysis: If you know the initial quantity, this is a recursive problem, so reverse thinking is OK. It's a recursive problem, haha. * When the recursion ends on the tenth day, the amount is one. This monkey can really eat!!! */ public class Monkey { public int peach(int peach,int day) { if(day==1) return peach; return peach((peach+1)*2,day-1); } /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Monkey monkey=new Monkey(); System.out.printf("The monkey picked it on the first day.%d A peach.\n",monkey.peach(1, 10)); System.out.printf("The monkey had it on the second day.%d A peach.\n",monkey.peach(1, 9)); System.out.printf("The monkey had it on day 3.%d A peach.\n",monkey.peach(1, 8)); System.out.printf("On the fourth day, monkeys had%d A peach.\n",monkey.peach(1, 7)); System.out.printf("The monkeys had it on day 5.%d A peach.\n",monkey.peach(1, 6)); System.out.printf("The monkey had it on day 6.%d A peach.\n",monkey.peach(1, 5)); System.out.printf("On the seventh day, monkeys had%d A peach.\n",monkey.peach(1, 4)); System.out.printf("On the eighth day, monkeys had%d A peach.\n",monkey.peach(1, 3)); System.out.printf("The monkey had it on the 9th day.%d A peach.\n",monkey.peach(1, 2)); System.out.printf("The monkey had it on day 10.%d A peach.\n",monkey.peach(1, 1)); } }
package javaimprove018; /* * [Program 18] Prog.java Topic: Two table tennis teams compete, each with three players. The first team is a, B and c, and the second team is x, y and Z. The competition list has been decided by lot. The players were asked about the list of matches. a c says he's not compared with x and Z. Please program to find out the names of the three teams. Problem Analysis: Solving with Matrix Thought */ public class PingPong { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub int[][] abcxyz=new int[3][3]; for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { if(i==0&&j==0||i==2&&j==0||i==2&&j==2) abcxyz[i][j]=0; else abcxyz[i][j]=1; } } System.out.println("The competition is arranged as follows:"); for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { if(abcxyz[i][j]==1) { if(i==0) { System.out.printf("a"); } if(i==1) { System.out.printf("b"); } if(i==2) { System.out.printf("c"); } if(j==0) { System.out.printf(" VS x\n"); } if(j==1) { System.out.printf(" VS y\n"); } if(j==2) { System.out.printf(" VS z\n"); } } } } } }
package javaimprove019; import java.util.Scanner; /* * [Program 19] LingXing.java Title: Print out the following pattern (diamond) * *** ***** ******* ***** *** * Problem analysis: Here we can use the function relation of x,y, i, j to judge. In my program, I can see that for this topic to draw an image: x(j)In the coordinate system equivalent to y in the usual environment, the expression judgment range of four diamond-shaped edges is deduced at one time. */ public class Print { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Please enter the diamond height:"); Scanner in=new Scanner(System.in); int size=in.nextInt(); if(size%2==0) { size+=1;//The figure obtained by odd numbers will be more accurate. In addition, the higher the height of the figure, the more accurate the figure will be. } for(int i=0;i<size;i++) { for(int j=0;j<size;j++) { if(i<=size/2&&j>=size/2-i&&j<=size/2+i) { System.out.print("*"); }else if(i>size/2&&j>=i-size/2&&j<=3*size/2-i) { System.out.print("*"); }else { System.out.print(" "); } } System.out.println(); } System.out.println("--------------------------------"); for(int i=0;i<size;i++) { for(int j=0;j<size;j++) { if(j<=size/2&&i>=size/2-j&&i<=size/2+j) { System.out.print("*"); }else { System.out.print(" "); } } System.out.println(); } } }
package javaimprove020; /* * [Program 20] TestAdd2.java Title: There is a fraction sequence: 2/1, 3/2, 5/3, 8/5, 13/8, 21/13.. Find out the sum of the top 20 items of this sequence. Problem analysis: Find out the rules of fractional sequence. */ public class Fraction { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub double up=2; double down=1; double temp; double sum=0; for(int count=1;count<=20;count++) { sum+=up/down; temp=down; down=up; up=temp+up; System.out.printf("The front of the sequence%d The sum of items is:%f\n",count,sum); } System.out.printf("The sum of the first twenty terms of the sequence is:%f",sum); } }