•  помогите пожалуйста Вставка лаб_№5(Массивы), 6(матрицы) С/С++ языки программирования высокого уровня структуры данных



    Лаб_№5( Массивы)

    #include <iostream>


    #include <vector>


    using namespace std;


    int main()


    {


    vector <int> array(15);


    for (int i = 0; i < array.size(); i++)


    {


    array[i] = i;//заполняем вектор числами от 0 до длины вектора.


    if (array[i] % 2 == 0)


    {


    cout << array[i] << ""; // вывод только четных чисел.



    }


    }


    return 0;


    }





    Лаб_№6(матрицы)


    #include <iostream>


    #include <iomanip>


    #include <ctime>


    using namespace std;



    int main()


    {


    srand((int)time(0));


    int N, M, count_null, count_even, count_pos, max = 0;


    cout << "N="; cin >> N;


    cout << "M="; cin >> M;



    int** a = new int* [N];


    for (int i = 0; i < N; i++)


    a[i] = new int[M];



    for (int i = 0; i < N; i++)


    {


    count_null = 0;


    count_pos = 0;


    for (int j = 0; j < M; j++)


    {


    a[i][j] = rand() % 19 - 9;


    if (a[i][j] == 0) count_null++;


    if (a[i][j] > 0) count_pos++;


    cout << setw(3) << a[i][j] << " ";


    }


    if (i == 0 || count_pos > max) max = count_pos;



    if (count_null == 0)


    {


    count_even = 0;


    for (int j = 0; j < M; j++)


    if (a[i][j] % 2 == 0) count_even++;


    if (count_null == 0) cout << " count_even=" << count_even;


    }


    cout << endl;


    }



    for (int i = 0; i < N; i++)


    {


    count_pos = 0;


    for (int j = 0; j < M; j++)


    if (a[i][j] > 0) count_pos++;


    if (count_pos == max) cout << "Row " << i + 1 << " with max positive" << endl;


    }



    for (int i = 0; i < N; i++)


    delete[] a[i];


    delete[] a;



    system("pause");


    return 0;


    }






Ответы 1

  • ответ по ссылке: http://www.psu.ru/files/docs/personalnye-stranitsy- prepodavatelej/buzmakova/buzmakova1.pdf

  • Добавить свой ответ

Еще вопросы

Войти через Google

или

Забыли пароль?

У меня нет аккаунта, я хочу Зарегистрироваться

How much to ban the user?
1 hour 1 day 100 years