Advertisement
LabiinfaCibGyti

rgzvariant3

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