Главная » 2016 » Март » 15 » M6 33.2
08:59
M6 33.2

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

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

    //вывод матрицы
    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 c;
    int ii,jj;
    cout <<"Введите номера строк i,j"<<endl;
    cin>>ii>>jj;
    for (int j=0;j<m;j++)
    {
        c=a[ii][j];
        a[ii][j]=a[jj][j];
        a[jj][j]=c;
    }

    //вывод измененной матрицы
    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;
    }

    system("pause");
    return 0;
}

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