Технология программирования
C++
Главная »
2016 » Март » 4 » M6 9
|
#include <iostream>
#include <ctime>
using namespace std;
int main()
{
setlocale(LC_ALL,"rus_rus.1251");
srand(time(0));
const int n=25;
const int m=11;
double a[n][m];
//матрица
for (int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
a[i][j]=rand()%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 max=a[0][0];
for (int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if (a[i][j]>max)
max=a[i][j];
}
}
cout<<"max="<<max<<endl;
for (int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
a[i][j]=a[i][j]/max;
}
}
//вывод матрицы
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;
}
|
Просмотров: 318 |
Добавил: denjes
| Рейтинг: 0.0/0 |