(ここは大規模工事が必要なので…参考程度に)
#include <stdio.h> #define N 3 int main(void) { int i; double a[N], maxnorm0(); for (i = 0; i < N; i++) scanf("%lf", &a[i]); printf("maxnorm=%g\n", maxnorm0(a)); } double maxnorm0(.... |
#include <stdio.h> #define MAXN 1000 int main(void) { int i, n; double a[MAXN], maxnorm(); printf("input n (<= %d): ", MAXN); scanf("%d", &n); if (n > MAXN) exit(1); for (i = 0; i < n; i++) scanf("%lf", &a[i]); printf("maxnorm=%g\n", maxnorm(a, n)); } double maxnorm(.... |
#include <stdio.h> #include <stdlib.h> int main(void) { int i, n; double *a, maxnorm(); printf("input n: "); scanf("%d", &n); a = malloc(n * sizeof(double)); if (a == NULL) { fprintf(stderr, "メモリーが確保できません\n"); exit(1); } /* 以下、プログラムの字面は前問とまったく同じで OK */ for (i = 0; i < n; i++) scanf("%lf", &a[i]); printf("maxnorm=%g\n", maxnorm(a, n)); } double maxnorm(.... |