include iostream include cmath include conio using namespace std int 1

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <cmath>
#include <conio.h>
using namespace std;
int a[10000][10000];
int b[10000];
int main(){
int n, m, count = 0, k;
bool check1 = false, check2 = false;
printf("Vvedite razmer massiva\n");
scanf("%d%d", &n, &m);
printf ("Vvedite elementi massiva\n");
for (int q=0; q<n; q++)
for (int w=0; w<m; w++)
scanf("%d", &a[q][w]);
for (int q=0; q<n; q++){
check1 = false;
check2 = false;
for (int w=0; w<m-1; w++){
if (a[q][w+1] > a[q][w]){
if (check2 == true){
check1 = false;
check2 = false;
break;
}
check1 = true;
}
if (a[q][w+1] < a[q][w]){
if (check1 == true){
check1 = false;
check2 = false;
break;
}
check2 = true;
}
}
if (check1 == true)
printf("%d ", a[q][0]);
if (check2 == true)
printf("%d ", a[q][m-1]);
}
}