| 查看: 1204 | 回复: 4 | ||
[求助]
麻烦哪位大神帮忙修改一下这个程序,不胜感激! 已有2人参与
|
|
麻烦哪位大神帮忙看一下下面这个程序,编译的时候会提示While(true)处有错,应该怎么改,请告知一下,不胜感激! // stat.cpp : Defines the entry point for the console application. // #include <stdio.h> #include <stdlib.h> #include <math.h> #include <getopt.h> #include <string.h> // Show a simple usage information. void usage(); int main(int argc, char* argv[]) { char opt; // Options charactors int a=30, b=1, c=7; double r_critical = 3.3943e-2; // Critical radius for judging inner or outer double alpha = 1.0e-6; // Error critical for test double equal char ofname[255] = "out.txt"; // Output file name FILE *fin, *fout; unsigned int i = 0; // Treatment index double time = 0.0L; // Total sampling time double time_bak = 0.0L; // time backup unsigned int steps = 0; // Sampling times double y = 0.0L; // axis y pos double z = 0.0L; // axis z pos double r = 0.0L; // Radius double iq = 0.0L; // Irradiation quantity unsigned int inner = 0; // Inner sampling counter unsigned int outer = 0; // Outer sampling counter while ((opt = getopt(argc, argv, "a:b:c:e :r:h" ) != -1) {switch (opt) { case 'a': a = atoi(optarg); break; case 'b': b = atoi(optarg); break; case 'c': c = atoi(optarg); break; case 'e': alpha = atof(optarg); break; case 'o': strcpy(ofname, optarg); break; case 'r': r_critical = atof(optarg); break; case ':': // Go through case '?': // Go through case 'h': // Go through default: usage(); exit(0); }// switch }// while if (optind != argc-1) { fprintf(stderr, "Need a data file.\n" ;fprintf(stderr, "Use option -h to get some helpful message.\n" ;exit(1); } else // Open input & output files if ((fin = fopen(argv[optind], "r" )==NULL){ printf("data file: %s\n", argv[optind]); printf("Open input file %s failed!\n", argv[optind]); exit(1); } if ((fout = fopen(ofname, "w+" ) == NULL){ printf("Open/Create output file %s failed!\n", ofname); exit(1); } // Output table header fprintf(fout, "\tIndex\t\tTime\t\tSteps\t\tInner\t\tOuter\t\tRate\t\tIrradiation\n" ;fprintf(fout, "\t-------\t\t------\t\t------\t\t------\t\t------\t\t------\t\t------\n" ;// Read a line datas do { // Read a line, but just store useful data fscanf(fin, "%le%*le%*le%le%le%*le%*le%*le%*le%*le%*le%*le", &time, &y, &z); if (feof(fin)) // end of file { fprintf(fout, "\t%d\t\t%le\t%d\t\t%d\t\t%d\t\t%f\t\t%f\n", i, time_bak, steps, inner, outer, ((double)inner)/(inner + outer), iq); printf("\t%d\t\t%le\t%d\t\t%d\t\t%d\t\t%f\t\t%f\n", i, time_bak, steps, inner, outer, ((double)inner)/(inner + outer), iq); break; // out of repeat } if (time < alpha) // time == 0 means a new treatment { // Store treatment data if (i > 0) { fprintf(fout, "\t%d\t\t%le\t%d\t\t%d\t\t%d\t\t%f\t\t%f\n", i, time_bak, steps, inner, outer, ((double)inner)/(inner + outer), iq); printf("\t%d\t\t%le\t%d\t\t%d\t\t%d\t\t%f\t\t%f\n", i, time_bak, steps, inner, outer, ((double)inner)/(inner + outer), iq); } // Clear variable relative to treatment steps = 0; inner = 0; outer = 0; iq = 0; time_bak = 0; i++; // increment index } // Increment step counters steps++; // Calculate radius r = sqrt(y*y + z*z); if (r-r_critical > alpha) { outer++; } else { inner++; } // Calculate irradiation quantity //printf("r=%lf\n", r); iq += a*b*pow(10, -1*c*r)*fabs(time-time_bak); time_bak = time; } while (true); // Close files fclose(fin); fclose(fout); //printf("Calculate finished, press ENTER to exit." ;//printf("pow(10, 1) = %f", pow(10, 1)); //getchar(); return 0; } void usage() { printf("[Usage]: stat datafile.\n" ;printf("Options: \n" ;printf("\t-a, -b, -c: set coefficiency relatively.\n" ;printf("\t-o: set output file name.\n" ;printf("\t-e: set alpha used to compare two float number.\n" ;printf("\t-r: set referrence diameter.\n" ;printf("\nDeveloped by Sam <yeahspyme@sina.com>, published under GPL licence.\n" ;} |
» 猜你喜欢
不自信的我
已经有11人回复
北核录用
已经有3人回复
要不要辞职读博?
已经有6人回复
实验室接单子
已经有3人回复
磺酰氟产物,毕不了业了!
已经有8人回复
求助:我三月中下旬出站,青基依托单位怎么办?
已经有10人回复
26申博(荧光探针方向,有机合成)
已经有4人回复
论文终于录用啦!满足毕业条件了
已经有26人回复
2026年机械制造与材料应用国际会议 (ICMMMA 2026)
已经有4人回复
Cas 72-43-5需要30g,定制合成,能接单的留言
已经有8人回复
» 本主题相关价值贴推荐,对您同样有帮助:
请大神鉴定一枚植物(貌似长在树桩上,无法判断是菌类还是木本)
已经有5人回复
请大家帮忙解答一下,万分感谢!
已经有4人回复
求大神赐教。这个结构的名称是什么?
已经有4人回复
origin作图时这个图中的短线是怎么画出来的?有何意义?不胜感激。
已经有8人回复
求各位大神帮忙解释一下审稿人的评论,小硕不太理解,非常感谢~~~
已经有7人回复
求助各位大侠 大师 快来帮帮忙 小女子不胜感激啊 !!!
已经有5人回复
关于FSI流固耦合的问题
已经有4人回复
求大神帮忙解释截断能测试中的问题!
已经有7人回复
求大神翻译,解释,不胜感激
已经有21人回复
急急!各位路过的大神,帮帮忙,我被一个问题卡住了,希望各位指点迷津,小弟不胜感激
已经有19人回复
哪位大神帮忙翻译一下啊,关于混凝土自修复的,万分感激........
已经有5人回复
求大神用matlab给我处理一组数据,有人没有啊?
已经有15人回复
under review已经一个月收到邮件提醒文章提交不完整计划删除,求大神解惑
已经有21人回复
现有源程序,怎么用VC6.0编译加载到fluent中,希望大神帮我运行一下,本人不胜感激!
已经有10人回复
求各位大神指点一下,不胜感激!
已经有12人回复
下面这个拓扑图使用什么软件做的?谁有教程或者能教下,不胜感激~
已经有15人回复
国外科学技术核心期刊总览,有的麻烦传一份!不胜感激
已经有4人回复
HKU申请提交RP问题,求各位大神指教,不胜感激!
已经有10人回复
rbs
木虫 (小有名气)
- 应助: 32 (小学生)
- 金币: 3589.1
- 红花: 3
- 帖子: 221
- 在线: 16.3小时
- 虫号: 695603
- 注册: 2009-02-03
- 性别: GG
- 专业: 计算机应用技术
2楼2015-01-14 18:21:16
3楼2015-01-15 09:31:32
sxu2009
至尊木虫 (正式写手)
- 应助: 27 (小学生)
- 金币: 10463.7
- 散金: 744
- 红花: 5
- 帖子: 983
- 在线: 537小时
- 虫号: 861529
- 注册: 2009-10-01
- 性别: GG
- 专业: 计算机科学的基础理论
4楼2015-01-15 10:57:51
5楼2015-01-16 09:23:37












:r:h"
) != -1) {
回复此楼