注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
NG SWE intern -2024年11月
90分钟三道题,求加米!
. Waral dи,
第一道,FIZZBUZZ
When given a number N, for eachinteger i in the range from 1 to Ninclusive, print one value per line asfollows:
lf i is a multiple of both 3 and 5, print FizzBuzz.
lf i is a multiple of 3 but not 5, print Fizz.
lf i is a multiple of 5 but not 3, print Buzz.
If i is not a multiple of 3 or 5, print the value of i.
Write an algorithm which followsthe given instructions and prints therequired output.
Example
Input;
5
Output:. check 1point3acres for more.
1
2
Fizz
4
Buzz
第二道, DP
There is a set of N jars containing chocolates. Some of them may be empty, Determine the maximum number of chocolates Andrew can pick from the jars given that hecannot pick from jars next to each other.
Write an algorithm to find the maximum number of chocolatesthat can be picked from the jars insuch a way that the chocolates arenot picked from jars next to each other.. Χ
Input;
6 9 10 11 5 6 ..
Output:
26
第三道,矩阵运算
Write an algorithm which finds outthe elements which are largest in arow and smallest in a column in amatrix.
The first line of input consists of two space-separated integers-matrix row and matrix col,representing the number of rows in the matrix (N) and the number of columns in the matrix (M), respectively.
The next M lines consist of N space-separated integers representing the elements of the matrix.
Print a number which is largest in arow and smallest in a column in the given matrix.lf no element is found print '-1'
Input:
2 2
1 2
3 4
Output:
2 |