SHOW:
|
|
- or go back to the newest paste.
1 | #include <locale> | |
2 | - | #include "stdafx.h" |
2 | + | #include "stdio.h" |
3 | - | #include "conio.h" |
3 | + | void funk(int *b, int n); |
4 | - | void funk(int *b, int n, int m); |
4 | + | |
5 | { setlocale(LC_ALL, "Russian"); | |
6 | int n, m; | |
7 | printf("Укажите N и М для массива "); | |
8 | scanf("%d", &m); | |
9 | int **a = new int*[m]; | |
10 | scanf("%d", &n); | |
11 | for (int i = 0; i < m; i++) | |
12 | a[i] = new int[n]; | |
13 | printf("ВВедите числа масива"); | |
14 | for (int i = 0; i < m; i++) | |
15 | for (int j = 0; j < n; j++) | |
16 | scanf("%d", &a[i][j]); | |
17 | ||
18 | for (int i = 0; i < m; i++) { | |
19 | if ((i + 1) % 2 == 0) | |
20 | funk(a[i], n); | |
21 | - | funk(*a, n, m); |
21 | + | |
22 | for (int j = 0; j < n; j++) | |
23 | printf(" %d ", a[i][j]); | |
24 | ||
25 | } | |
26 | //getch(); | |
27 | - | getch(); |
27 | + | |
28 | delete[] a[i]; | |
29 | delete[] a; | |
30 | return 0; | |
31 | } | |
32 | void funk(int *a, int n ) { | |
33 | - | void funk(int *a, int n, int m ) { |
33 | + | for (int i = 0; i < n-1; ++i) |
34 | - | for (int i = 1; i < n; ++i) |
34 | + | { |
35 | - | { |
35 | + | for (int r = i+1; r < n; r++) |
36 | - | for (int r = 0; r < n - i; r++) |
36 | + | { |
37 | - | { |
37 | + | if (a[i] < a[r]) |
38 | - | if (a[r] < a[r + 1]) |
38 | + | { |
39 | - | { |
39 | + | int temp = a[r]; |
40 | - | int temp = a[r]; |
40 | + | a[r] = a[i]; |
41 | - | a[r] = a[r + 1]; |
41 | + | a[i] = temp; |
42 | - | a[r + 1] = temp; |
42 | + | |
43 | - | |
43 | + | |
44 | - | |
44 | + | } |
45 | - | } |
45 | + | } |
46 | - | } |
46 | + | } |
47 | ||
48 | } |