Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include "time.h"
- #include "rgzv5.h"
- using namespace std;
- int main()
- {
- setlocale(0, "Rus");
- int a[5][6],rez;
- cout<<"\tРГЗ по курсу Информатики"<<endl;
- cout<<"\tВариант №5."<<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 >> rez;
- cout<<endl;
- cout<<endl;
- cout<<endl;
- if (rez==1)
- {
- randommat(a);
- vivod(a);
- cout<<endl;
- cout<<endl;
- cout<<endl;
- }
- if (rez==2)
- {
- cout<<"Введите матрицу из 30 элементов"<<endl;
- klavamat(a);
- cout<<endl;
- vivod(a);
- cout<<endl;
- cout<<endl;
- cout<<endl;
- }
- if (rez==3)
- {
- vivod(a);
- summa(a);
- cout<<endl;
- cout<<"Сумма положительных элементов матрицы A= "<<summa(a)<<endl;
- cout<<endl;
- cout<<endl;
- cout<<endl;
- }
- if (rez==4)
- {
- vivod(a);
- cout<<endl;
- cout<<endl;
- cout<<endl;
- cout<<"Измененная матрица:"<<endl;
- cout<<endl;
- udvoenie(a);
- vivod(a);
- cout<<endl;
- cout<<endl;
- cout<<endl;
- }
- }while (rez>=1 && rez<=4);
- return 0;
- }
- #include "stdafx.h"
- #include <iostream>
- #include <math.h>
- #include "rgzv5.h"
- using namespace std;
- void randommat(int a[5][6])
- {
- int i,j;
- for (i=0;i<5;i++)
- {
- for (j=0;j<6;j++)
- {
- a[i][j]=-100+rand()%200;
- }
- }
- }
- void klavamat(int a[5][6])
- {
- int i,j;
- for( i=0;i<5;i++)
- {
- for (j=0;j<6;j++)
- {
- cin>>a[i][j];
- }
- }
- }
- int summa(int a[5][6])
- {
- int s=0, i, j;
- for (i=0;i<5;i++)
- {
- for (j=0;j<6;j++)
- {
- if (a[i][j]>0)
- s=s+a[i][j];
- }
- }
- return (s);
- }
- void udvoenie( int a[5][6])
- {
- int i,j;
- for (i=0;i<5;i++)
- {
- for (j=0;j<6;j++)
- {
- if (a[i][j]<0)
- a[i][j]=a[i][j]*2;
- }
- }
- }
- void vivod(int a[5][6])
- {
- int i,j;
- cout<<"Матрица A"<<endl;
- for (i=0;i<5;i++)
- {
- for (j=0;j<6;j++)
- {
- cout<< a[i][j]<<"\t";
- }
- cout << endl;
- }
- }
- #ifndef rgzv5_H
- #define rgzv5_H
- void randommat(int a[5][6]);
- void klavamat(int a[5][6]);
- int summa(int a[5][6]);
- void udvoenie( int a[5][6]);
- void vivod(int a[5][6]);
- #endif /*rgzv5_H*/
Advertisement
Add Comment
Please, Sign In to add comment