Advertisement
LabiinfaCibGyti

rgr.4

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