11.01 - int length = a.Length > b.Length ? a.Length : b.Length;
int[] r = new int [length];
for(int i = 0; i < length; i++){
if(a.Length <= i){
r[i] = Math.Abs(b[i]);
continue;
}
if(b.Length <= i){
r[i] = (a[i]);
continue;
}
r[i] = Math.Abs(b[i] - a[i]);
}
return r;
11.02 - int total = a.Length * amount;
string[] r = new string [total];
int z = 0;
for(int i = 0; i < a.Length; i++){
for(int j = 0; j < amount; j++){
r[z++] = a[i];
}
}
return r;
11.03 - i have no idea
11.04 - int[] r = new int [list.Length];
for(int i = 0; i < list.Length; i++){
r[i] = list[i] % modBy;
}
return r;
11.05 - int res = (list.Length + 1)/2;
string[] r = new string[res];
for(int i = 0, j = 0; i < list.Length; i = i + 2, j++){
if(i >= list.Length - 1){
r[j] = list[i];
} else {
r[j] = list[i] + list[i + 1];
}
}
return r;
11.06 - string []r = new string [grades.Length];
for(int i = 0; i < grades.Length; i++){
if(grades[i] >= D){
r[i] = "D";
}
if(grades[i] >= C){
r[i] = "C";
}
if(grades[i] >= B){
r[i] = "B";
}
if(grades[i] >= A){
r[i] = "A";
}
if(grades[i] < D){
r[i] = "E";
}
}
return r;
11.07 - string [][]r = new string[input.Length][];
for(int i = 0; i < input.Length; i++){
r[i] = new string[input.Length];
for(int j = 0; j < input.Length; j++){
r[i][j] = input[j][i];
}
}
return r;
using System;
ReplyDeletepublic class Program {
public static bool Puzzle(int[][] input) {
int sum1 = 0;
int sum2 = 0;
for (int i = 0; i < input.Length; i++) {
sum1 += input[i][i];
sum2 += input[i][input.Length - 1 - i];
}
return sum1 == sum2;
}
}
11.03
Delete