質問編集履歴
1
質問の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,9 +2,7 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
解決しましたありがとうございました
|
8
6
|
|
9
7
|
### 発生している問題・エラーメッセージ
|
10
8
|
|
@@ -38,65 +36,7 @@
|
|
38
36
|
|
39
37
|
{
|
40
38
|
|
41
|
-
double n, delta =1.0e-3;
|
42
|
-
|
43
|
-
for(i=0;i<len;i++){
|
44
|
-
|
45
|
-
t=(double)i*delta;
|
46
|
-
|
47
|
-
for(n=1;n<N+1;n++){
|
48
|
-
|
49
|
-
f = 2*n-1;
|
50
|
-
|
51
|
-
a =4/(M_PI*(2*n-1));
|
52
|
-
|
53
|
-
X += a*sin(2.0*M_PI*f*t);
|
54
|
-
|
55
|
-
|
39
|
+
d
|
56
|
-
|
57
|
-
d[i] = X;
|
58
|
-
|
59
|
-
X=0;
|
60
|
-
|
61
|
-
return 0;
|
62
|
-
|
63
|
-
}
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
int main(void){
|
68
|
-
|
69
|
-
int i=10000, len=1000;
|
70
|
-
|
71
|
-
double X, t, f, a, N, d[i],x;
|
72
|
-
|
73
|
-
printf("N:");
|
74
|
-
|
75
|
-
scanf("%d",&N);
|
76
|
-
|
77
|
-
printf("time x(N=%d)\n",N);
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
x = calculation(i,len,X,t,f,a,N,&d[0]);
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
FILE *fp;
|
86
|
-
|
87
|
-
fp = fopen("20266044_rectangularwave.txt","w");
|
88
|
-
|
89
|
-
fprintf(fp,"time x(N=%d)\n",N);
|
90
|
-
|
91
|
-
for(i=0;i<len;i++){
|
92
|
-
|
93
|
-
printf("%lf %lf\n", t, x);
|
94
|
-
|
95
|
-
fprintf(fp,"%lf %lf\n",t,x);
|
96
|
-
|
97
|
-
}
|
98
|
-
|
99
|
-
fclose(fp);
|
100
40
|
|
101
41
|
return 0;
|
102
42
|
|