Advertisement
LabiinfaCibGyti

rgz4

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