| ²é¿´: 1247 | »Ø¸´: 4 | ||
liupeipingгæ (³õÈëÎÄ̳)
|
[ÇóÖú]
Âé·³ÄÄλ´óÉñ°ïæÐÞ¸ÄÒ»ÏÂÕâ¸ö³ÌÐò£¬²»Ê¤¸Ð¼¤£¡ ÒÑÓÐ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" ;} |
» ²ÂÄãϲ»¶
Ò»Ö¾Ô¸Ö£ÖÝ´óѧ085600Çóµ÷¼Á
ÒѾÓÐ3È˻ظ´
Çóµ÷¼Á Ò»Ö¾Ô¸Î÷ÄϽ»Í¨´óѧ085701»·¾³¹¤³Ì 282·Ö
ÒѾÓÐ7È˻ظ´
Çóµ÷¼Á
ÒѾÓÐ15È˻ظ´
²ÄÁÏר˶283Çóµ÷¼Á
ÒѾÓÐ15È˻ظ´
£¨µ÷¼Á£©Ò»Ö¾Ô¸±¨¿¼¹þ¶û±õ¹¤Òµ´óѧ0857×ÊÔ´Óë»·¾³×¨Òµ378·Ö¿¼Éú
ÒѾÓÐ3È˻ظ´
±¾¿Æ211£¬293·ÖÇëÇóµ÷¼Á
ÒѾÓÐ9È˻ظ´
315Çóµ÷¼Á
ÒѾÓÐ4È˻ظ´
308Çóµ÷¼Á
ÒѾÓÐ4È˻ظ´
301Çóµ÷¼Á
ÒѾÓÐ4È˻ظ´
304Çóµ÷¼Á
ÒѾÓÐ5È˻ظ´
» ±¾Ö÷ÌâÏà¹Ø¼ÛÖµÌùÍÆ¼ö£¬¶ÔÄúͬÑùÓаïÖú:
Çë´óÉñ¼ø¶¨Ò»Ã¶Ö²Îï£¨Ã²ËÆ³¤ÔÚÊ÷×®ÉÏ£¬ÎÞ·¨ÅжÏÊǾúÀ໹ÊÇľ±¾£©
ÒѾÓÐ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
liupeiping
гæ (³õÈëÎÄ̳)
- Ó¦Öú: 0 (Ó×¶ùÔ°)
- ½ð±Ò: 54.5
- Ìû×Ó: 6
- ÔÚÏß: 8.8Сʱ
- ³æºÅ: 3461137
- ×¢²á: 2014-10-08
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
liupeiping
гæ (³õÈëÎÄ̳)
- Ó¦Öú: 0 (Ó×¶ùÔ°)
- ½ð±Ò: 54.5
- Ìû×Ó: 6
- ÔÚÏß: 8.8Сʱ
- ³æºÅ: 3461137
- ×¢²á: 2014-10-08
5Â¥2015-01-16 09:23:37














:r:h"
) != -1) {
»Ø¸´´ËÂ¥