ページ 11

質問があります お願いします

Posted: 2012年7月21日(土) 22:00
by yuka
私はy=exp[-x^2/2]のグラフを−3<x<3の範囲でグラフ化したいのですが以下のプログラムで実行するとxとyが変化しません。どこが間違っているのでしょうか?

#include <stdio.h>
#include <math.h>
#define num 100

int main(void) {
float x[num],y[num]; float step_size;
int step;
step_size=6/num; for(step=0;step<num;step++){
x[step]=(-3)+step_size*step;
y[step]=exp((-1)*x[step]*x[step]/2);
}
/* data output */
FILE *fp;
fp = fopen("exp.csv","w");
for (step=0;step<num;step++){ fprintf(fp,"%f,%f\n",x[step],y[step]); printf("%f,%f\n",x[step],y[step]);
} fclose(fp);
return 0; } 

Re: 質問があります お願いします

Posted: 2012年7月21日(土) 22:03
by みけCAT
とりあえず、コードのインデントを整え、codeタグを使用して貼り直してみましょう。

Re: 質問があります お願いします

Posted: 2012年7月22日(日) 03:42
by asd
こちらのスレッドで継続中のようです。

codeタグ
http://dixq.net/forum/viewtopic.php?f=3&t=11116