Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include "time.h"
- #include "rgzvar3.h"
- using namespace std;
- int main()
- {
- setlocale(0, "Rus");
- double a[4][4],v;
- cout<<"\tРГЗ по курсу Информатики"<<endl;
- cout<<"\tВариант №3."<<endl;
- cout<<"\tВыполнила Любовь Будко,"<<endl;
- cout<<"\tСтудентка группы РС-92"<<endl;
- cout<<endl;
- do
- {
- cout<<"Введите:"<<endl;
- cout<<"1) Для задачи матрицы случайчными числами"<<endl;
- cout<<"2) Для ввода матрицы с клавиатуры"<<endl;
- cout<<"3) Для поиска количества нулевых элементов матрицы"<<endl;
- cout<<"4) Для уменьшения положительных элементов на число равное двум"<<endl;
- cout<<endl;
- cout<<"Выберите пункт меню:\n";
- cin >> v;
- cout<<endl;
- cout<<endl;
- cout<<endl;
- if (v==1)
- {
- random(a);
- vivod(a);
- cout<<endl;
- cout<<endl;
- cout<<endl;
- }
- if (v==2)
- {
- cout<<"Введите матрицу из 16 элементов"<<endl;
- klava(a);
- cout<<endl;
- vivod(a);
- cout<<endl;
- cout<<endl;
- cout<<endl;
- }
- if (v==3)
- {
- vivod(a);
- kolvonull(a);
- cout<<endl;
- cout<<"Количество нулевых элементов в Матрице А= "<<kolvonull(a)<<endl;
- cout<<endl;
- cout<<endl;
- cout<<endl;
- }
- if (v==4)
- {
- vivod(a);
- cout<<endl;
- cout<<endl;
- cout<<endl;
- cout<<"Измененная матрица:"<<endl;
- cout<<endl;
- umensheniepol(a);
- vivod(a);
- cout<<endl;
- cout<<endl;
- cout<<endl;
- }
- }while (v>=1 && v<=4);
- return 0;
- }
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- #include "rgzvar3.h"
- using namespace std;
- void random(double a[4][4])
- {
- int i,j;
- for (i=0;i<4;i++)
- {
- for (j=0;j<4;j++)
- {
- a[i][j]=-100+rand()%200;
- }
- }
- }
- void klava(double a[4][4])
- {
- int i,j;
- for( i=0;i<4;i++)
- {
- for (j=0;j<4;j++)
- {
- cin>>a[i][j];
- }
- }
- }
- double kolvonull(double a[4][4])
- {
- int kol=0, i, j;
- for (i=0;i<4;i++)
- {
- for (j=0;j<4;j++)
- {
- if (a[i][j]==0)
- kol++;
- }
- }
- return (kol);
- }
- void umensheniepol( double a[4][4])
- {
- int i,j;
- for (i=0;i<4;i++)
- {
- for (j=0;j<4;j++)
- {
- if (a[i][j]>0)
- a[i][j]=a[i][j]-2;
- }
- }
- }
- void vivod(double a[4][4])
- {
- int i,j;
- cout<<"Матрица A"<<endl;
- for (i=0;i<4;i++)
- {
- for (j=0;j<4;j++)
- {
- cout<< a[i][j]<<"\t";
- }
- cout << endl;
- }
- }
- #ifndef rgzvar3_H
- #define rgzvar3_H
- void random(double a[4][4]);
- void klava(double a[4][4]);
- double kolvonull(double a[4][4]);
- void umensheniepol( double a[4][4]);
- void vivod(double a[4][4]);
- #endif /*rgzvar3_H*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement