LabiinfaCibGyti

rgr24

Dec 7th, 2019
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4. #include "24bibl.h"
  5. using namespace std;
  6. int _tmain(int argc, _TCHAR* argv[])
  7. {
  8.     int a[5][6], i, j;
  9.     setlocale (0,"rus");
  10.     cout<<"Матрица 1"<<endl;
  11.     func3(a);
  12.     cout<<endl;
  13.     cout<<"Сумма положительных элементов= "<<func(a)<<endl;
  14.     cout<<endl;
  15.     cout<<"Измененная матрица"<<endl;
  16.     func2(a);
  17.     for (i=0;i<5;i++)
  18.     {
  19.         for (j=0;j<6;j++)
  20.         {
  21.             cout<<a[i][j]<<"\t";
  22.         }
  23.         cout<<endl;
  24.     }
  25.     return 0;
  26. }
  27.  
  28.  
  29.  
  30.  
  31.  
  32. #include "stdafx.h"
  33. #include <iostream>
  34. #include <math.h>
  35. #include "24bibl.h"
  36. using namespace std;
  37. double func(int a[5][6])
  38. {  
  39.     int i, j, p=0;
  40.     for (i=0; i<5; i++)
  41.         {
  42.             for (j=0; j<6; j++)
  43.             {
  44.                 if (a[i][j]>0)
  45.             p=p+a[i][j];
  46.         }
  47.     }
  48. return (p);    
  49. }
  50. void func2(int a[5][6])
  51. {
  52.     int i, j;
  53.     for (i=0; i<5; i++)
  54.     {
  55.         for (j=0; j<6; j++)
  56.         {
  57.              if (a[i][j]<0)
  58.                  a[i][j]=a[i][j]*3;
  59.         }
  60.     }
  61. }
  62. void func3 (int a[5][6])
  63. {
  64.     int i, j;
  65.     for (i=0;i<5;i++)
  66.     {
  67.         for (j=0;j<6;j++)
  68.         {
  69.             a[i][j]=-10+rand()%20;
  70.         }
  71.     }
  72. for (i=0;i<5;i++)
  73.     {
  74.         for (j=0;j<6;j++)
  75.         {
  76.             cout<<a[i][j]<<"\t";
  77.         }
  78.         cout<<endl;
  79. }
  80. }
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88. double func(int a[5][6]);
  89. void func2 (int a[5][6]);
  90. void func3 (int a[5][6]);
Advertisement
Add Comment
Please, Sign In to add comment