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.

Revisions

  1. fenske created this gist Nov 13, 2019.
    57 changes: 57 additions & 0 deletions 2019-11-13-1.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,57 @@
    #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;
    }