Question 1:
Title Description:
Many Web pages will show hyperlinks to other pages, such as some search pages listing the entries you search for. In some Web pages, hyperlinks that have been clicked by the user are changed to a different color.
Suppose a page has n hyperlinks at the beginning, 1-n numbered from top to bottom, each hyperlink appears as a string, and all hyperlinks appear blue at first. Now give the hyperlinks that the user clicked,
Once a hyperlink has been clicked, it will turn from blue to purple, please output all the last hyperlinks that are still not blue.
Input:
The first line enters an integer n, followed by n lines, one string per line, representing the name of each hyperlink, with a name of only lowercase letters, no more than 20 in length, and all names are different. (1<=n<=100)
Next, enter an integer m, indicating that the user clicked on a m hyperlink, and the last M row represents the name of the hyperlink that the user clicked, and the M may have duplicates.
Output:
Output several lines, one name per line, all the names of the hyperlinks that are still blue, the order of names sorted by dictionary, and if all are purple, do not output directly.
Sample input:
5Sinaqqtaobaojdbaidu3qqbaidubaidu
Sample output:
Sinatoabaojd
Code:
1 ImportJava.util.*;2 Public classMeituan1 {3 Public Static voidMain (string[] args) {4Scanner sc=NewScanner (system.in);5 while(Sc.hasnextline ()) {6 intn=Integer.parseint (Sc.nextline ());7String[] Arr=NewString[n];8 for(inti=0;i<arr.length;i++){9arr[i]=sc.nextline ();Ten } One intm=Integer.parseint (Sc.nextline ()); AString[] Arr2=NewString[m]; -Treeset<string> ts=NewTreeset<string>(); -Treeset<string> ts2=NewTreeset<string>(); the for(inti=0;i<arr2.length;i++){ -arr2[i]=sc.nextline (); - if(!ts.contains (Arr2[i])) { - Ts.add (Arr2[i]); + } - } + for(inti=0;i<arr.length;i++){ A if(!ts.contains (Arr[i])) { at Ts2.add (Arr[i]); - } - } - for(String s:ts2) { - System.out.println (s); - } in } - } to}
View Code
Question 2
Title Description:
Time always gave his daughter Rin a magic table, but the hand of the magic meter always pointed to the strange place, so Rin decided to repair the table, the current table pointer pointing to a direction N1 (0~359度, North is 0 degrees, east direction is 90 degrees),
She needs to adjust the needle to the direction of the N2, she can choose clockwise, can also rotate counterclockwise rotation of the needle, if the clockwise rotation angle will increase, counterclockwise angle decrease. When rotated clockwise to 359 degrees, the rotation is once back to 0 degrees.
Rin wants the needle to rotate as small as possible, that is, to rotate the shortest path to the right direction. Please tell him how to rotate. When there are multiple modes of rotation and the angle of rotation is the same, a clockwise rotation is selected.
Input:
The first line contains an integer n1 that represents the direction of the current pointer
The second line contains an integer n2 that indicates the direction the pointer should point to (0<=n1,n2<=359)
Output:
If a clockwise rotation is required, the output X
If you need to rotate counterclockwise, output-X
Sample input:
315 45
45 270
Sample output:
90-135
The code is as follows:
1 ImportJava.util.*;2 classRotClock13 {4 Public Static voidMain (string[] args)5 {6Scanner sc =NewScanner (system.in);7SYSTEM.OUT.PRINTLN ("Input 2 numbers:");8 intN1 =sc.nextint ();9 intN2 =sc.nextint ();Ten intN11 = 0; One if(n1>=180) A { -N11 = n1-180; - if(N2>=0 && n2<=N11) the { -System.out.print (360-n1+n2); -}Else - { +System.out.print (n2-N1); - } + A}Else at { -N11 = n1+180; - if(N2>n11 && n2<=359) - { -System.out.print (-n1-360+n2); - } in Else{ -System.out.print (n2-N1); to } + } - } the}
View Code
Overall, the group's two questions are still very simple.
2017 US reviews web front-end Online programming questions (1) (2)