#include <iostream>
#include <fstream>
using namespace std;
int main() {
const int n = 5;
int a[n][n];
int S = 0;
ifstream fin("text.txt"); // открыли файл для чтения
for (int j=0; j< n; j++){
for (int i =0; i < n; i++)
{
fin >> a[i][j];
cout << a[i][j] << " ";
}cout << endl;
}
for (int j =0; j < n; j++){
for (int i = 0; i< n; i++)
{
S+=a[i][j];
}
}
cout <<"S =" << S <<"\n";
int summ1 = 0;
int summ2 = 0;
for(int k =0; k < n; k++){
switch (a[k][0]){
case 1:
{
for (int k1 =1; k1 < n; k1++){
summ1 += a[k][k1];
}
}
case 2:
{
for (int k1 =1; k1 < n; k1++){
summ2 += a[k][k1];
}
}
}}
cout << "summ1=" << summ1 <<"\n";
cout << "summ2=" << summ2 <<"\n";
cin.get();
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewpjb25zdCBpbnQgbiA9IDU7CgppbnQgYVtuXVtuXTsKaW50IFMgPSAwOwoKICAgIGlmc3RyZWFtIGZpbigidGV4dC50eHQiKTsgLy8g0L7RgtC60YDRi9C70Lgg0YTQsNC50Lsg0LTQu9GPINGH0YLQtdC90LjRjwoJZm9yIChpbnQgaj0wOyBqPCBuOyBqKyspewogZm9yIChpbnQgaSA9MDsgaSA8IG47IGkrKykKIHsKCSAJICAgZmluID4+IGFbaV1bal07CgkJICAgY291dCA8PCBhW2ldW2pdIDw8ICIgIjsKCQkgICAKCQkgICAKCQkgICAKfWNvdXQgPDwgZW5kbDsKCX0KCWZvciAoaW50IGogPTA7IGogPCBuOyBqKyspewoJCglmb3IgKGludCBpID0gMDsgaTwgbjsgaSsrKQoJewoJCVMrPWFbaV1bal07Cgl9Cgl9Cgljb3V0IDw8IlMgPSIgPDwgUyA8PCJcbiI7CglpbnQgc3VtbTEgPSAwOwoJaW50IHN1bW0yID0gMDsKCWZvcihpbnQgayA9MDsgayA8IG47IGsrKyl7CgkJ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