Главная » 2016 » Март » 11 » M6 21a
12:16
M6 21a

#include <iostream>
#include <ctime>
using namespace std;
int main()
{
    setlocale(LC_ALL,"rus_rus.1251");
    srand(time(0));
    const double pi=3.1415926535897;
    const int n=25;
    const int m=11;
    double a[n][m];
    double b[n];

    //матрица
    for (int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
           a[i][j]=(rand()%30)/pi;
        }
    }

    //вывод матрицы
    cout.setf(ios::fixed);
    cout.width(7);
    cout.precision(2); 
    cout<<"Матрица A:"<<endl;
    for (int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
           cout<<a[i][j]<<"   ";
        }
        cout<<endl;
    }
    
    //обработка матрицы
    double max;
    for (int i=0;i<n;i++)
    {
        max=a[i][0];
        for(int j=0;j<m;j++)
        {
           if (a[i][j]>max)
               max=a[i][j];
        }
        b[i]=max;
    }

    //вывод массива
    cout.setf(ios::fixed);
    cout.width(7);
    cout.precision(2); 
    cout<<"Массив B:"<<endl;
    for (int i=0;i<n;i++)
    {
        cout<<b[i]<<endl;
    }

    system("pause");
    return 0;
}

Просмотров: 304 | Добавил: denjes | Рейтинг: 5.0/1
Всего комментариев: 0
avatar