Advertisement
LabiinfaCibGyti

rgz20

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