Advertisement
LabiinfaCibGyti

rgz30

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