#include <iostream>
#include <vector>
using namespace std;
int main() {int m, n, cx, cy;
cin >> m >> n;
vector<int>a;
a.reserve(m*n);
for (int i = 0;i < m;++i) {
for(int j = 0;j < n;++j) {
int v;
cin >> v;
a.push_back(v);
}
}
int x;
int value = 0;
cin >> x;
for (int k = 0;k < x;++k) {
cin >> cx >> cy;
if((a[cy-1 + (cx-1)*cy]) != -100) {
value += a[cy-1 + (cx-1)*cy];
a[cy-1 + (cx-1)*cy] = -100;
}
}cout << value;
}
Объяснение:
import random
def GenEx(count):
signs = ['+', '-', '*', '/']
for _ in range(count):
fn = random.randint(-20, 20)
sn = random.randint(-20, 20)
ex = '{0} {1} {2}'.format(fn, random.choice(signs), sn)
yield (ex + ' = ?', eval(ex))
IsGameRun = True
while IsGameRun:
TrueAnsws = 0
for ex, check in GenEx(2):
print(ex)
resvAnsw = float(input())
if resvAnsw == check: TrueAnsws += 1;
IsRetry = input('You correctly solved '+str(TrueAnsws)+' examples. Do you want to try again? Y/N \n')
if IsRetry == 'Y': IsGameRun = True
else: IsGameRun = False
Объяснение: