BUPT-homework/semester1/pset13/2-1-malloc.c

25 lines
360 B
C
Raw Permalink Normal View History

2021-12-10 23:31:54 +08:00
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int n;
scanf("%d", &n);
int *arr = malloc(n * sizeof(int));
for (int i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
for (int i = 0; i < n; i++) {
arr[i] = arr[i] * -10;
}
for (int i = 0; i < n - 1; i++) {
printf("%d ", arr[i]);
}
printf("%d\n", arr[n - 1]);
free(arr);
return 0;
}