Programmer Written Exam Didi 2021 Test Development Engineer Programming Questions Collection and Arrangement (7)

1. The annual X Stars Track and Field Games was grandly opened. Xiao Xiao X signed up to participate in the jumping competition. This is what Xiao Xiao X does best! The jumping competition is divided into two rounds, one is to increase and the other is to long jump. The final result will be determined based on the results of the two rounds, and the results of the two rounds will each have half the weight in the calculation of the final result. Now that you know the rankings of Xiaoxiao X in the high jump and long jump competitions, please write a program to help Xiao X calculate the final result ranking, Xiao X can get the second best and worst rankings.
Input description:
Each group of input contains a test sample, each test sample contains three lines. The
first line is n, which means the number of participants (n<=26). The
second line is n unique capital letters, which means n people. Ranking according to the high jump performance from best to worst. In the
third line, enter n non-repeated capital letters to indicate the ranking of n individuals according to the long jump performance from best to worst
[Each character corresponds to a contestant, there is no same ranking In the case of X, X represents a small X, and two characters are separated by a space.
Output description:
output one line, including two numbers, which are the best and worst positions of Xiaoxiao X in the final ranking. The two numbers are separated by spaces.
Sample input:
10
ABCDEFXHIJ
ACIXEFJHDB
Sample output:
3 8
prompts : In the
two competitions, A and C are ranked before Xiaoxiao X, so Xiaoxiao X's final ranking is best to be third. In
both competitions, J and H are ranked behind Xiaoxiao X, so Xiaoxiao X The final ranking is at least eighth

2. Xiao Ming had a dream last night, in which many Fibonacci numbers became a snake. Suddenly, the largest number became a snake's head, and Xiao Ming swallowed it in his stomach. Xiao Ming was frightened awake, he quickly drew a Fibonacci snake on the paper.

34 21 13
1 1 8
2 3 5

This is a serpentine Fibonacci sequence. It is an n*n matrix. In the above matrix, n=3, the first row and the first column are the maximum, and then the numbers gradually change in a clockwise order. small.
The following is the situation when n=4:

987 610 377 233
5 3 2 144
8 1 1 89
13 21 34 55

Xiaoming hopes that you can write a program that inputs a positive integer n, and then outputs the elements of the Fibonacci snake matrix row by row.
Input description: a
single group of input, the input data occupies one line, including a positive integer n, which represents the size of the Fibonacci snake matrix (n<10).
Output description: the
output data occupies one line, row by row (from the first row) Start to the nth row, the first row starts from the first column to the nth column) output the elements in the Fibonacci snake-shaped matrix, separated by a space between every two numbers.
Sample input:
3
Sample output:
34 21 13
1 1 8
2 3 5

Guess you like

Origin blog.csdn.net/qq_34124009/article/details/108196852