C++程式,處理 fortran 的輸出
by 高顯忠, 2010-12-08 14:44, 人氣(2926)
#if 0
然後 產生 autocad script file 的範例
ct1= 1, x= 0.000000, y= 0.000000
ct1= 2, x= 0.196350, y= 0.195090
ct1= 3, x= 0.392699, y= 0.382683
ct1= 4, x= 0.589049, y= 0.555570
ct1= 5, x= 0.785398, y= 0.707107
ct1= 6, x= 0.981748, y= 0.831470
ct1= 7, x= 1.178097, y= 0.923880
ct1= 8, x= 1.374447, y= 0.980785
ct1= 9, x= 1.570796, y= 1.000000
ct1= 10, x= 1.767146, y= 0.980785
ct1= 11, x= 1.963495, y= 0.923880
ct1= 12, x= 2.159845, y= 0.831470
ct1= 13, x= 2.356194, y= 0.707107
ct1= 14, x= 2.552544, y= 0.555570
ct1= 15, x= 2.748894, y= 0.382683
ct1= 16, x= 2.945243, y= 0.195090
ct1= 17, x= 3.141593, y= 0.000000
Press [Esc] for stop! other key for continue...
#endif
// ----------------------------------------------
#include "inc-01.h"
#include "sj-01.h"
#include "sj-02.h"
// ----------------------------------------------
int main()
{
FILE *f1, *f2;
double x, y;
f1= fopen("plot-sin.txt", "rt");
f2= fopen("plot-sin.scr", "wt");
int ct1= 0, ct2;
fprintf(f2, "spline\n");
while (!feof(f1)) {
ct2= fscanf(f1, "%lf %lf", &x, &y);
if (ct2 != 2) break;
ct1++;
printf("ct1= %3d, x= %.6lf, y= %.6lf\n", ct1, x, y);
fprintf(f2, "%.6lf,%.6lf\n", x, y);
}
fprintf(f2, "\n\n\n");
fclose(f1);
fclose(f2);
pause();
return 0;
}// end of main()
討論
編號 | 標題 | 回應 | 讚 | 最後發表 |
2540 | 1 | 0 | ||