Advertisement
venik2405

lab1_1_3

Sep 10th, 2021
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #include <stdio.h>
  2. #define size 6
  3.  
  4. void main(void) {
  5. int M[size][size];
  6. int i, j, a, flag;
  7. for (i = 0; i < size; i++) {
  8. for (j = 0; j < size; j++) {
  9. do {
  10. printf("Enter element with index [%d|%d]: ", i + 1, j + 1, "\n");
  11. scanf_s("%d", &a);
  12. if ((a > 100) || (a < -100))
  13. {
  14. printf("Enter the number, which is higher than -100 and lower than 100");
  15. flag = 1;
  16. }
  17. else {
  18. flag = 0;
  19. }
  20. } while (flag == 1);
  21. M[i][j] = a;
  22. }
  23. }
  24. printf("Your matrix: \n");
  25. for (i = 0; i < size; i++) {
  26. for (j = 0; j < size; j++) {
  27. printf(" %d", M[i][j]);
  28. }
  29. printf("\n");
  30. }
  31. int num = M[0][0];
  32. for (i = 0; i < size; i++) {
  33. for (j = 0; j < size; j++) {
  34. if (M[i][j] >= num) {
  35. num = M[i][j];
  36. }
  37. }
  38. }
  39. printf("The biggest number is %d\n", num);
  40. printf("Indexes of the biggest elements from the matrix:\n");
  41. for (i = 0; i < size; i++) {
  42. for (j = 0; j < size; j++) {
  43. if (M[i][j] == num) {
  44. printf("[%d|%d]\n", i + 1, j + 1);
  45. }
  46. }
  47. }
  48. getch();
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement