It's National Day holiday, but I don't feel much relaxed.
Alone in a foreign country, I suddenly find that I no longer like special nodes like holidays and birthdays. It is easier to feel at ease on the usual days of class and study. Perhaps the more special, the more calm it is.
In fact, sometimes I forget to be lonely, I can use my time alone before bed, reading, writing, fitness, programming, and I don't think the world is missing anything. I think I'm strong enough to keep my day stable. But on the eve of holidays, everything is empty and almost everyone is planning to do something. Just like a magnesia lamp, the lamp lights itself up in pitch black.I didn't conquer or even get used to loneliness, but it just didn't come. Usually I would feel that such a world belongs to me and is free. Now I am staring at the dark deep silence around me, some of my heart is blocked. Life, I can't break myself up, it's hard, it's like cutting down, this process is not easy. So although I keep going, I can't go out in the wind and chill.Move.
Turn off the lights, leave, and generally enter the elevator in a calm manner. Meet a classmate who is sitting back with a takeaway. Just pretend to say it's a relaxed vacation. But when the elevator door opens again, it's just the last look and walk away. Halfway, I suddenly want to turn to the supermarket I usually go to and buy some discounted fruits. It's often said that loneliness is itself a cool thing.It's hard for me to feel the same thing. But under the big neon-flashing screen at the supermarket entrance, I suddenly feel my shadow on the front floor, which is a bit cool.
What are you going to do on vacation?
I said: Very good
package com.situ9_30; import java.util.Calendar; public class National_Day_operation {//National Day Work wqw //java2109 public static void main(String[] args) { // TODO auto-generated method stub //1. Hawking predicts a catastrophic destruction of the planet in 2215. Calculate the distance from the end of Hawking's prediction. //How many days, hours, minutes, seconds are left. //Format: 12 days 05:43 minutes 24 seconds, the results will be output. answer1(); System.out.println(); System.out.println(); //2. Print a 15-layer Yang Hui triangle. answer2(15);//Number of input layers System.out.println(); System.out.println(); //3. Decompose a positive integer into prime factors. For example, enter 90 and print out 90 = 2 x 3 x 3 x 5. answer3(11); //Enter the number to decompose System.out.println(); System.out.println(); //4. Stitch the two arrays together. answer4(6, 5);//Two random array lengths System.out.println(); System.out.println(); //5. Move all elements of an array three bits to the right, keeping the length of the array constant // If it exceeds the length of the array, it is automatically added to the array header. answer5(3);//Enter the number of digits to move right System.out.println(); System.out.println(); //Additional Question: Implement the product operation of two large numbers. answer6(4, 4); //Enter large digits } private static void answer1() {//Hawking's Prediction Calendar cal=Calendar.getInstance(); int y=cal.get(Calendar.YEAR); int m=cal.get(Calendar.MONTH); int d=cal.get(Calendar.DATE); int h=cal.get(Calendar.HOUR_OF_DAY); int mi=cal.get(Calendar.MINUTE); int s=cal.get(Calendar.SECOND); //2215 int year,month=0,day = 0,hour,min,sec; //year for( year=y ;year<2215;year++) {//2021-2215 if((year%4==0&&year%100!=0)||year%400==0) { day=day+366; }else { day=day+365; } } //month for( month=m+1 ;month<=12;month++) { if((month==1||month==3||month==5||month==7||month==8||month==10||month==12)) day=31+day; else if((month==4||month==6||month==9||month==11)) day=30+day; else if(month==2) { if((year%4==0&&year%100!=0)||year%400==0)//Leap year day=29+day; else day=28+day; } } //day month=m; if((month==1||month==3||month==5||month==7||month==8||month==10||month==12)) day=day+31-d; else if((month==4||month==6||month==9||month==11)) day=day+30-d; else if(month==2) { if((year%4==0&&year%100!=0)||year%400==0)//Leap year day=day+29-d; else { day=day+28-d;} } //hour hour=23-h; //Minute min=59-mi; //second sec=60-s; System.out.print("The moment is now"+y+"year"+m+"month"+d+"day"+h+"time"+mi+"branch"+s+"second"); System.out.println("There's still time to Hawking's prediction"+day+"day"+hour+"time"+min+"branch"+sec+"second"); } //------------------------------------------------------------------------ private static void answer2(int n) {//Yang Hui Triangle // TODO auto-generated method stub // Create a two-dimensional array that stores the values of each row in Yang Hui's triangle int[][] array = new int[n][n]; // Assigning values to array elements for (int i = 0; i < array.length; i++) { // Value of each row array[i] = new int[i + 1]; // Assigning values to first and last elements array[i][0] = array[i][i] = 1; // Assigning values to non-first and last elements of each row if (i > 1) { for (int j = 1; j < array[i].length - 1; j++) { array[i][j] = array[i - 1][j - 1] + array[i - 1][j]; } } } //output for (int i = 0; i < array.length; i++) { // Output space in front of Yang Hui triangle number for (int j = 0; j < array.length - 1 - i; j++) { System.out.print(" "); } for (int j = 0; j <= i; j++) { // Fill empty positions with spaces System.out.print(" "); // Output, Bit Width 3, Left Aligned System.out.printf("%-3d", array[i][j]); } System.out.println(); } } //------------------------------------------------------------------------ private static void answer3(int m) {//Positive integer factorization prime factor. // TODO auto-generated method stubs e.g. input 60, print out 60 = 2 x 2 x 3 x 5 if(m==1||m==2||m==3||m==5||m==7) { System.out.println(m+"Prime factor"); }else { int k=0; int m1=m; int m2=m; for(int i=2;i!=m1;) {//Statistics have several decomposable prime factors if(m1%i==0) { m1=m1/i; k++; }else{ i++; } if(m1==i) k++; } int j=0; // System.out.println(k); int[] a=new int[k];//Prime factor quantity for(int i=2;i<=m1;) { if(m2 % i ==0) { m2=m2/i; a[j]=i; j++; if(m2==i) a[j]=i; }else{ i++; } } if(k==0||k==1) { System.out.println(m+"Prime factor"); }else { System.out.print(m+"="); for(int i=0;i<a.length;i++) { if(i==0) System.out.print(a[i]); else System.out.print("*"+a[i]); } } } } //------------------------------------------------------------------------ private static void answer4(int m,int n) {//Split the two arrays first and last. // TODO auto-generated method stub int[] a = new int[m]; for(int i= 0; i<a.length; i++) { a[i] = (int)( Math.random()*Math.random()*100); } int[] b = new int[n]; for(int i= 0; i<b.length; i++) { b[i] = (int)( Math.random()*Math.random()*100); } //-------------------- Randomly generate two arrays------- int max=a.length+b.length; int[] c = new int[max]; for(int i= 0; i<a.length; i++) { c[i] = a[i]; } for(int i= a.length; i<c.length; i++) { c[i] = b[i-a.length]; } //End to end, output System.out.println("Array 1"); for(int i= 0; i<a.length; i++) { System.out.print(a[i]+" "); } System.out.println(); System.out.println("Array 2"); for(int i= 0; i<b.length; i++) { System.out.print(b[i]+" "); } System.out.println(); System.out.println("Array end to end"); for(int i= 0; i<c.length; i++) { System.out.print(c[i]+" " ); } } //------------------------------------------------------------------------ private static void answer5(int k) {//Move all elements of an array three bits to the right as a whole // TODO auto-generated method stub int[] nums = new int[9]; for(int i= 0; i<nums.length; i++) { nums[i] = (int)( Math.random()*Math.random()*100); }//Generate Random Array //After the new array a record is moved int n=nums.length; int[] a = new int[nums.length + k]; //Move k bits for(int i=0;i<nums.length;i++){ a[(i+k)%n]=nums[i]; } //------------ Output System.out.println("Random Array"); for(int i=0;i<nums.length;i++) { System.out.print(nums[i]+" "); } System.out.println(); System.out.println("Move right"+k+"Array after bits"); for(int i=0;i<nums.length;i++) { System.out.print(a[i]+" "); } } //------------------------------------------------------------------------ private static void answer6(int m,int n) {//Multiplication of large numbers (essentially string multiplication) //Entering a large number and converting individual digits into an array index can be cumbersome and difficult, but multiplying the arrays is tricky // Two large numbers a, b, one result c int[] a = new int[m]; for(int i= 0; i<a.length; i++) { a[i] = (int)( Math.random()*10); } int[] b = new int[n]; for(int i= 0; i<b.length; i++) { b[i] = (int)( Math.random()*10); } int max=a.length+b.length; int[] c = new int[max]; //------------------------- if (a.equals("0") || b.equals("0")) { System.out.println(0); }//Multiply if zero is zero else { //-------------------------------------------------------------------------- Multiplication // =================================== // // Specific cannot be written out, only ideas // // =================================== //output System.out.println("First Large Number"); for(int i= 0; i<a.length; i++) { System.out.print(a[i]); } System.out.println(); System.out.println("Second Major Number"); for(int i= 0; i<b.length; i++) { System.out.print(b[i]); } System.out.println(); System.out.println("Multiplication of Large Numbers"); for(int i= 0; i<c.length; i++) { System.out.print(c[i]); } } } //------------------------------------------------------------------------ }