Всем привет, имеется вот такой код написанный на C#
public static int[,] funk(int[,] S)
{
int width = S.GetLength(0);
int height = S.GetLength(1);
int[,] result = new int[width, height];
result[0, 0] = S[0, 0];
for (int x = 1; x < width; x++)
result[x, 0] = S[x, 0] + result[x - 1, 0];
for (int y = 1; y < height; y++)
result[0, y] = S[0, y] + result[0, y - 1];
for (int y = 1; y < height; y++)
for (int x = 1; x < width; x++)
result[x, y] = S[x, y] + result[x - 1, y] + result[x, y - 1] - result[x - 1, y - 1];
return result;
}
Ребят помогите пожалуйста перевести его на python, я пыталась, но что-то делаю не так…
def funk():
w = 100.0
h = 100.0
x = 1.0
y = 1.0
si = [0.0, 0.0]
result = [w, h]
result [0.0, 0.0] = si[0.0, 0.0]
for x in range(w):
x +=1
result[x, 0] = si[x, 0] + result[x - 1, 0]
for y in range(h):
y +=1
result[0, y] = si[0, y] + result[0, y - 1]
for x in range(w):
x +=1
for y in range(h):
y +=1
result[x, y] = si[x, y] + result[x - 1, y] + result[x, y - 1] - result[x - 1, y - 1]
return result
За ранее спасибо….