Advertisement
Amorf

Untitled

Sep 8th, 2021
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int arr[10][10];
  4.  
  5. int pos_max(int i){
  6.     int max = 0;
  7.     for (int j = 0; j < 10; j++) {
  8.         if (arr[i][j] > arr[i][max]) {
  9.             max = j;
  10.         }
  11.     }
  12.     return max;
  13. }
  14.  
  15. int main() {
  16.     int i;
  17.     int j;
  18.     int flag = 0;
  19.     char c;
  20.     int max = 0;
  21.     printf("Input arr: \n");
  22.     for (i = 0; i < 10; i++){
  23.         for (j = 0; j < 10; j++){
  24.             while (scanf("%d%c", &arr[i][j], &c) != 2 && c != '/n'){
  25.                 rewind(stdin);
  26.                 printf("Try again\n");
  27.             }
  28.         }
  29.     }
  30.     for (i = 0; i < 10; i++) {
  31.         for (j = 0; j < 10; j++) {
  32.             printf("arr[%d][%d] = %d\n",i + 1,j +1, arr[i][j]);
  33.         }
  34.     }
  35.     for (i = 0; i < 10; i++) {
  36.         max = pos_max(i);
  37.         for (j = 0; j < 10; j++) {
  38.             if (arr[j][max] < arr[i][max]) {
  39.                 break;
  40.             }
  41.         }
  42.         if (j == 10) {
  43.             printf("Saddle points are: ") ;
  44.             printf("arr[%d][%d] = %d\n",i + 1,max +1, arr[i][max]);
  45.             flag = 1;
  46.         }
  47.     }
  48.     if (flag == 0) {
  49.         printf("No saddle points\n");
  50.     }
  51.     return 0;
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement