Advertisement
LabiinfaCibGyti

rgz27

Dec 12th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.69 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include "time.h"
  4. #include "rgz27.h"
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     setlocale(0, "Rus");
  10.     int a[5][5],an;
  11.         cout<<"\tРГЗ по курсу Информатики"<<endl;
  12.         cout<<"\tВариант №27."<<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) Для увеличения отрицательных элементов матрицы на 4"<<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<<"Введите матрицу из 25 элементов"<<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.                 kolvopol(a);
  51.                 cout<<endl;
  52.                 cout<<"Кол-во положительных элементов матрицы A= "<<kolvopol(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.                 uvelotr(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. #include "stdafx.h"
  87. #include <iostream>
  88. #include <math.h>  
  89. #include "rgz27.h"
  90. using namespace std;
  91.  
  92. void random(int a[5][5])
  93. {
  94.     int i,j;
  95.     for (i=0;i<5;i++)
  96.     {
  97.         for (j=0;j<5;j++)
  98.         {
  99.             a[i][j]=-100+rand()%200;
  100.         }
  101.     }
  102. }
  103. void klava(int a[5][5])
  104. {
  105.     int i,j;
  106.     for( i=0;i<5;i++)
  107.     {
  108.         for (j=0;j<5;j++)
  109.         {
  110.             cin>>a[i][j];
  111.         }
  112.     }
  113. }
  114. int kolvopol(int a[5][5])
  115. {
  116.     int s=0, i, j;
  117.     for (i=0;i<5;i++)
  118.     {
  119.         for (j=0;j<5;j++)
  120.         {
  121.             if (a[i][j]>0)
  122.                 s=s+1;
  123.         }
  124.     }
  125. return (s);
  126. }
  127. void uvelotr( int a[5][5])
  128. {
  129.     int i,j;
  130.     for (i=0;i<5;i++)
  131.     {
  132.         for (j=0;j<5;j++)
  133.         {
  134.             if (a[i][j]<0)
  135.                 a[i][j]=a[i][j]+4;
  136.         }
  137.     }
  138. }
  139. void vivod(int a[5][5])
  140. {
  141.     int i,j;
  142.     cout<<"Матрица A"<<endl;
  143.     for (i=0;i<5;i++)
  144.     {
  145.         for (j=0;j<5;j++)
  146.         {
  147.             cout<< a[i][j]<<"\t";
  148.         }
  149.         cout << endl;
  150.     }
  151. }
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163. #ifndef rgz27_H
  164. #define rgz27_H
  165. void random(int a[5][5]);
  166. void klava(int a[5][5]);
  167. int kolvopol(int a[5][5]);
  168. void uvelotr( int a[5][5]);
  169. void vivod(int a[5][5]);
  170. #endif /*rgz27_H*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement