Advertisement
LabiinfaCibGyti

rgz22

Dec 9th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.99 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4. #include "22bibl.h"
  5. using namespace std;
  6. int _tmain(int argc, _TCHAR* argv[])
  7. {
  8.     int a[4][4], i, j, k,r;
  9.     setlocale (0,"rus");
  10.     for (;;)
  11.     {
  12.     cout << "1)Матрица 1" << endl;
  13.     cout << endl;
  14.     cout << "2)Сумма положительных элементов= " << endl;
  15.     cout << endl;
  16.     cout << "3)Измененная матрица:" << endl;
  17.     cout << "Выберите пункт меню:" << endl;
  18.     cin >> r;
  19.     cout << endl;
  20.     cout << endl;
  21.     cout << endl;
  22.     if (r == 1)
  23.     {
  24.         cout<<"Матрица 1"<<endl;
  25.         func3(a);
  26.         cout<<endl;
  27.         cout<<endl;
  28.         cout<<endl;
  29.     }
  30.     if (r == 2)
  31.     {
  32.         k=func(a);
  33.         cout<<"Кол-во элементов кратных 5= "<<k<<endl;
  34.         cout<<endl;
  35.         cout<<endl;
  36.         cout<<endl;
  37.     }
  38.     if (r == 3)
  39.     {
  40.         cout<<"Измененная матрица"<<endl;
  41.         func(a);
  42.         func2(a);
  43.         for (i=0;i<4;i++)
  44.         {
  45.             for (j=0;j<4;j++)
  46.             {
  47.                 cout<<a[i][j]<<"\t";
  48.             }
  49.             cout<<endl;
  50.         }
  51.         cout<<endl;
  52.         cout<<endl;
  53.         cout<<endl;
  54.     }
  55.     if (r != 1 && r != 2 && r != 3) {
  56. break;
  57.     }
  58.     }
  59.     return 0;
  60. }
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. #include "stdafx.h"
  71. #include <iostream>
  72. #include <math.h>
  73. #include "22bibl.h"
  74. using namespace std;
  75. double func(int a[4][4])
  76. {  
  77.     int i, j, k=0;
  78.     for (i=0; i<4; i++)
  79.         {
  80.             for (j=0; j<4; j++)
  81.             {
  82.                 if (a[i][j]%5==0)
  83.             k++;
  84.         }
  85.     }
  86. return (k);    
  87. }
  88. void func2(int a[4][4])
  89. {
  90.     int i, j;
  91.     for (i=0; i<4; i++)
  92.     {
  93.         for (j=0;j<4;j++)
  94.         {
  95.             if (a[i][j]>0)
  96.                 a[i][j]=a[i][j]-4;
  97.         }
  98.     }
  99. }
  100. void func3 (int a[4][4])
  101. {
  102.     int i, j;
  103.     for (i=0;i<4;i++)
  104.     {
  105.         for (j=0;j<4;j++)
  106.         {
  107.             a[i][j]=-10+rand()%20;
  108.         }
  109.     }
  110. for (i=0;i<4;i++)
  111.     {
  112.         for (j=0;j<4;j++)
  113.         {
  114.             cout<<a[i][j]<<"\t";
  115.         }
  116.         cout<<endl;
  117. }
  118. }
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125. double func(int a[4][4]);
  126. void func2 (int a[4][4]);
  127. void func3 (int a[4][4]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement