x = r * sin(theta) * cos(phi); y = r * sin(theta) * sin(phi); z = r * cos(theta); |
d2p(x, y, z, &r, &theta, &phi); |
#include <stdio.h> #define N 3 main() { 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 main() { 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 <malloc.h> main() { int i, n; double *a, maxnorm(); printf("input n: "); scanf("%d", &n); a = (double *)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(.... |