Advertisement
minilose

Untitled

Jan 9th, 2021
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. void input(int a[4][4])
  4. {
  5. cout << "Input array:" << endl;
  6. for (int i = 0; i < 4; i++)
  7. {
  8. for (int j = 0; j < 4; j++)
  9. {
  10. cout << "a[" << i << "][" << j << "]=";
  11. cin >> a[i][j];
  12. }
  13. }
  14. }
  15. void diagcheck(int a[4][4])
  16. {
  17. int countcheck = 0;
  18. for (int i = 0; i < 4; i++)
  19. {
  20. for (int j = 0; j < 4; j++)
  21. {
  22. if (i==j)
  23. {
  24. if (a[i][j] != 0)
  25. {
  26. countcheck++;
  27. }
  28. }
  29. }
  30. }
  31. if (countcheck != 0)
  32. {
  33. cout << "Ima elementi ot glavniq diagonal, koito ne sa ravni na nula!" << endl;
  34. }
  35. else
  36. {
  37. cout << "Vsichki elementi ot glavniq diagonal sa ravni na nula!" << endl;
  38. }
  39. }
  40. void main()
  41. {
  42. int a[4][4];
  43. input(a);
  44. diagcheck(a);
  45. system("pause");
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement