Skip to content

Instantly share code, notes, and snippets.

@fenske
Created November 13, 2019 18:14
Show Gist options
  • Select an option

  • Save fenske/58bb4c53bb885dff95f5c3a5fb682c7f to your computer and use it in GitHub Desktop.

Select an option

Save fenske/58bb4c53bb885dff95f5c3a5fb682c7f to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cmath>
using namespace std;
#define N 3
// Количество строк матрицы А, сумма элементов каждой из которых меньше нуля.
void f(int x[N], int y[N]) {
int k = 0;
for (int i = 0; i < N; i++) {
cout << x[i] << " ";
}
cout << endl;
for (int i = 0; i < N; i++) {
cout << y[i] << " ";
}
cout << endl;
int t[N];
t[0] = INT_MIN;
t[1] = INT_MIN;
t[2] = INT_MIN;
for (int i = 0; i < N; i++) {
if (y[i] > x[i])
t[i] = y[i];
else {
t[i] = x[i];
k++;
}
}
for (int i = 0; i < N; i++) {
cout << t[i] << " ";
}
cout << endl;
cout << "k = " << k << endl;
}
int main() {
int x[N];
x[0] = 1;
x[1] = 5;
x[2] = 3;
int y[N];
y[0] = 4;
y[1] = 2;
y[2] = 6;
f(x, y);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment