Advertisement
LabiinfaCibGyti

rgz4

Dec 15th, 2019
104
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 "rgzvariant4.h"
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     setlocale(0, "Rus");
  10.     double a[6][6],vibor;
  11.         cout<<"\tРГЗ по курсу Информатики"<<endl;
  12.         cout<<"\tВариант №4."<<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) Для увеличения первой строки на 10"<<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<<"Введите матрицу из 36 элементов"<<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.                 sumotrelem(a);
  51.                 cout<<endl;
  52.                 cout<<"Сумма отрицательных элементов в Матрице А= "<<sumotrelem(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.                 uvelperstr(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. #include "stdafx.h"
  86. #include <iostream>
  87. #include <math.h>  
  88. #include "rgzvariant4.h"
  89. using namespace std;
  90.  
  91. void random(double a[6][6])
  92. {
  93.     int i,j;
  94.     for (i=0;i<6;i++)
  95.     {
  96.         for (j=0;j<6;j++)
  97.         {
  98.             a[i][j]=-100+rand()%200;
  99.         }
  100.     }
  101. }
  102. void klava(double a[6][6])
  103. {
  104.     int i,j;
  105.     for( i=0;i<6;i++)
  106.     {
  107.         for (j=0;j<6;j++)
  108.         {
  109.             cin>>a[i][j];
  110.         }
  111.     }
  112. }
  113. double sumotrelem(double a[6][6])
  114. {
  115.     int i, j, sum=0;
  116.     for (i=0;i<6;i++)
  117.     {
  118.         for (j=0;j<6;j++)
  119.         {
  120.             if (a[i][j]<0)
  121.                 sum=sum+a[i][j];
  122.         }
  123.     }
  124. return (sum);
  125. }
  126. void uvelperstr( double a[6][6])
  127. {
  128.     int j;
  129.     for (j=0;j<6;j++)
  130.     {
  131.         a[0][j]=a[0][j]+10;
  132.     }
  133. }
  134. void vivod(double a[6][6])
  135. {
  136.     int i,j;
  137.     cout<<"Матрица A"<<endl;
  138.     for (i=0;i<6;i++)
  139.     {
  140.         for (j=0;j<6;j++)
  141.         {
  142.             cout<< a[i][j]<<"\t";
  143.         }
  144.         cout << endl;
  145.     }
  146. }
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158. #ifndef rgzvariant4_H
  159. #define rgzvariant4_H
  160. void random(double a[6][6]);
  161. void klava(double a[6][6]);
  162. double sumotrelem(double a[6][6]);
  163. void uvelperstr( double a[6][6]);
  164. void vivod(double a[6][6]);
  165. #endif /*rgzvariant4_H*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement