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
#include <stdio.h>
#define MAX_SIZE 50
int main(int argc, char *argv[])
{
int a[MAX_SIZE], tmp;
int length = 0;
while(scanf("%d", &tmp) == 1) {
if(length == MAX_SIZE) {
printf("Too many numbers.\n");
break;
}
a[length] = tmp;
length++;
}
// Print the array forwards
for(int i = 0; i < length; i++) {
printf("%d, ", a[i]);
}
printf("\n");
// Print the array backwards
for(int i = length - 1; i >= 0; i--) {
printf("%d, ", a[i]);
}
printf("\n");
return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX