Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Щеглов В.А. 19ВИ1
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int nechet_stolb(int n,int m,int** a){
- int i,j,nech_stolb=-1,b=0;
- for(j=0;j<n;j++){
- for(i=0;i<m;i++){
- if(a[i][j]%2==1) b++;
- }
- if(b==m) {nech_stolb=j+1;
- break;
- }
- b=0;
- }
- return nech_stolb;
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int i,n,m,b,j;
- b=0;
- cout<<"Введите кол-во строк в матрице: ";
- cin>>m;
- cout<<"Введите кол-во столбцов в матрице: ";
- cin>>n;
- int** a=new int*[m];
- for(i=0;i<m;i++){
- a[i]=new int[n];
- }
- cout<<"Все элементы матрицы:\n";
- for(i=0;i<=m-1;i++){
- for(j=0;j<n;j++){
- a[i][j]=rand()%10000;
- cout<<setw(6)<<a[i][j];
- }
- cout<<endl;
- }
- b=nechet_stolb(n,m,a);
- if(b==-1)cout<<"Нет ни одного столбца со всеми нечётными элементами"; else
- cout<<"Номер первого столбца со всеми нечётными элементами="<<b;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment