Advertisement
Guest User

Untitled

a guest
Dec 16th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include "math.h"
  4. using namespace std;
  5. int main()
  6. {
  7. int s, m = 1, sum=0;
  8. cout « "Enter the matrix size : " « endl;
  9. cin » s;
  10.  
  11. int **array = new int*[s];
  12.  
  13. for (int i = 0; i < s; i++)
  14. {
  15. array[i] = new int[s];
  16. }
  17.  
  18. for (int i = 0; i < s; i++)
  19. {
  20. for (int j = 0; j < s; j++) {
  21. cout « "Enter the [" « i « "] [" « j « "] element: ";
  22. cin » array[i][j];
  23. }
  24. }
  25. cout « "Result : " « endl;
  26. bool ans = false;
  27. for (int i = 0; i < s; i++) {
  28. for (int j = 0; j < s; j++) {
  29. if ((array[i][j] < 0)) {
  30. ans = true;
  31. cout « "[" « array[i][j] « "]";
  32. }
  33. }
  34. }
  35.  
  36. if (ans == false)
  37. cout « "No elements." « endl;
  38. system("pause");
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement