Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <ctime>
- #include <stdlib.h>
- using namespace std;
- int main()
- { setlocale(LC_ALL, "rus");
- int n, m, k, i, j, nashel;
- cout<<"Введите размеры массива"<<endl;
- cout<<"Количество столбцов "; cin>>n;
- if (!cin){cout<<"Ошибка! Нечисловой ввод!"<<endl; return 1;}
- cout<<"Количество строчек "; cin>>m;
- if (!cin){cout<<"Ошибка! Нечисловой ввод!"<<endl; return 1;}
- double **x=new double*[m];
- double *sum=new double[m];
- for(i=0;i<m;i++)
- {
- x[i]=new double[n];
- sum[i]=0;
- }
- for(j=0; j<m; j++)
- {for(k=0; k<n;k++)
- {
- cout<<"x["<<j+1<<"]["<<k+1<<"]="; cin>>x[j][k];
- }
- }
- nashel=0;
- for(j=0; j<m; j++)
- {for(k=0; k<n;k++)
- {
- if(nashel==1)
- {
- sum[j]+=x[j][k];
- if(k==n-1) nashel=0;
- continue;
- }
- if(x[j][k]<0)
- {
- j=-1;
- nashel=1;
- break;
- }
- }
- }
- for(i=0;i<m;i++)
- {
- if (sum[i]!=0)
- {
- cout<<"В "<<i+1<<"строке было отрицательное число; сумма элементов равна "<<sum[i]<<endl;
- }
- delete[] x[i];
- }
- delete [] x,sum;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement