06.04.2014, 16:03. Просмотров 279. Ответов 2
C++ |
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
45
46
47
48
| #include <stdio.h>
#include <conio.h>
#include <windows.h>
const int n=9;
int a[n], b[n];
inline int pr(void) {
printf("a: ");
for(int i=0; i<n; i++) {
printf("%d ", a[i]);
}
printf("\nb: ");
for(int i=0; i<n; i++) {
printf("%d ", b[i]);
}
printf("\n\n");
return 0;
}
int main() {
for(int i=0; i<n; i++) {
a[i]=i;
b[i]=i+n;
}
pr();
int c[n]; //temp
for(int i=0; i<n; i++) {
c[i] = b[i];
}
int *ptrA = a;
int *ptrB = b;
//move A array to B array position
memmove(ptrB, a, sizeof(a[0]) * n);
//move B array to A array position
memmove(ptrA, c, sizeof(c[0]) * n);
pr();
_getch();
return 0;
} |
|
программа меняет массивы метвми....а как сделать что б я мог с клавиатурры вводить любые два массива????