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