Advertisement
LabiinfaCibGyti

rgz12

Dec 15th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.66 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include "time.h"
  4. #include "rgz12.h"
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     setlocale(0, "Rus");
  10.     double a[6][6],rez;
  11.         cout<<"\tРГЗ по курсу Информатики"<<endl;
  12.         cout<<"\tВариант №12."<<endl;
  13.         cout<<"\tВыполнил Михалев Данил,"<<endl;
  14.         cout<<"\tСтудент группы РС-92"<<endl;
  15.         cout<<endl;
  16.         do
  17.         {
  18.             cout<<"Введите:"<<endl;
  19.             cout<<"1) Для задачи матрицы случайчными числами"<<endl;
  20.             cout<<"2) Для ввода матрицы с клавиатуры"<<endl;
  21.             cout<<"3) Для поиска количества отрицательных элементов побочной диагонали матрицы"<<endl;
  22.             cout<<"4) Для увеличения элементов главной диагонали на 6"<<endl;
  23.             cout<<endl;
  24.             cout<<"Выберите пункт меню:\n";
  25.             cin >> rez;
  26.             cout<<endl;
  27.             cout<<endl;
  28.             cout<<endl;
  29.             if (rez==1)
  30.             {
  31.                 random(a);
  32.                 vivod(a);
  33.                 cout<<endl;
  34.                 cout<<endl;
  35.                 cout<<endl;
  36.             }
  37.             if (rez==2)
  38.             {
  39.                 cout<<"Введите матрицу из 36 элементов"<<endl;
  40.                 klava(a);
  41.                 cout<<endl;
  42.                 vivod(a);
  43.                 cout<<endl;
  44.                 cout<<endl;
  45.                 cout<<endl;
  46.             }
  47.             if (rez==3)
  48.             {
  49.                 vivod(a);
  50.                 kolotrpob(a);
  51.                 cout<<endl;
  52.                 cout<<"Количество отрицательных элементов в побочной диагонали в Матрице А= "<<kolotrpob(a)<<endl;
  53.                 cout<<endl;
  54.                 cout<<endl;
  55.                 cout<<endl;
  56.             }
  57.             if (rez==4)
  58.             {
  59.                 vivod(a);
  60.                 cout<<endl;
  61.                 cout<<endl;
  62.                 cout<<endl;
  63.                 cout<<"Измененная матрица:"<<endl;
  64.                 cout<<endl;
  65.                 yvelglav(a);
  66.                 vivod(a);
  67.                 cout<<endl;
  68.                 cout<<endl;
  69.                 cout<<endl;
  70.             }
  71.         }while (rez>=1 && rez<=4);
  72.         return 0;
  73. }
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. #include "stdafx.h"
  82. #include <iostream>
  83. #include <math.h>  
  84. #include "rgz12.h"
  85. using namespace std;
  86.  
  87. void random(double a[6][6])
  88. {
  89.     int i,j;
  90.     for (i=0;i<6;i++)
  91.     {
  92.         for (j=0;j<6;j++)
  93.         {
  94.             a[i][j]=-100+rand()%200;
  95.         }
  96.     }
  97. }
  98. void klava(double a[6][6])
  99. {
  100.     int i,j;
  101.     for( i=0;i<6;i++)
  102.     {
  103.         for (j=0;j<6;j++)
  104.         {
  105.             cin>>a[i][j];
  106.         }
  107.     }
  108. }
  109. double kolotrpob(double a[6][6])
  110. {
  111.     int i, j=5, kol=0;
  112.     for (i=0;i<6;i++)
  113.     {
  114.         if (a[i][j]<0)
  115.             kol++;
  116.         j--;
  117.     }
  118. return (kol);
  119. }
  120. void yvelglav( double a[6][6])
  121. {
  122.     int i;
  123.     for (i=0;i<6;i++)
  124.     {
  125.         a[i][i]=a[i][i]+6;
  126.     }
  127. }
  128. void vivod(double a[6][6])
  129. {
  130.     int i,j;
  131.     cout<<"Матрица A"<<endl;
  132.     for (i=0;i<6;i++)
  133.     {
  134.         for (j=0;j<6;j++)
  135.         {
  136.             cout<< a[i][j]<<"\t";
  137.         }
  138.         cout << endl;
  139.     }
  140. }
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155. #ifndef rgz12_H
  156. #define rgz12_H
  157. void random(double a[6][6]);
  158. void klava(double a[6][6]);
  159. double kolotrpob(double a[6][6]);
  160. void yvelglav( double a[6][6]);
  161. void vivod(double a[6][6]);
  162. #endif /*rgz12_H*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement