evcamels

timp-1_var-13

Dec 17th, 2021
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. int main(){
  5. int arr[100][100];
  6. vector <int> a;
  7. int n;
  8. cout << "Введите размер матрицы: ";
  9. cin >> n;
  10. cout << "Введите матрицу: " << endl;
  11. for(int i=0;i<n;i++){
  12. for(int j=0;j<n;j++){
  13. cin >> arr[i][j];
  14. }
  15. }
  16. for(int i=0;i<n;i++){
  17. for(int j=0;j<n;j++){
  18. if(j<i){
  19. a.push_back(arr[i][j]);
  20. }
  21. }
  22. }
  23. int sum = 0;
  24. for(int i=0;i<a.size();i++){
  25. sum+=a[i];
  26. }
  27. if(sum == 0){
  28. cout << "Матрица верхняя треугольная!" << endl;
  29. }else cout << "Матрица не верхняя треугольная!" << endl;
  30. return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment