compute-diff-goodput.c

来自「对IEEE 802.11e里的分布式信道接入算法EDCA进行改进」· C语言 代码 · 共 70 行

C
70
字号
/* This programm compute the Gain on goodput comparing with the basic EDCF , the commandline used is : compute-diff-goodput AEDCF-file-of-goodput EDCF-file-of-goodput output-file */#include <stdio.h>#include <stdlib.h>/* Compute the maximum between the number in   * the second column                  *  * Input: *   src1, src2 - two columns files * *   res - two column file */int main(int argc, char **argv) {  FILE *df1, *df2,*df3 ;  	int nodes;	  float ratio;  	float good1;	float good2;		ratio = 0.0;	good2 =0.0;  good1 =0.0;  if (argc != 4) {    //printf("Ussage: %s srcfile nflows \n", argv[0]);    exit(-1);  }  if (!(df1 = fopen (argv[1], "r"))) {    printf ("fopen() failed\n");    exit (1);  }	if (!(df2 = fopen (argv[2], "r"))) {    printf ("fopen() failed\n");    exit (1);  }  if (!(df3 = fopen (argv[3], "w"))) {    printf ("fopen() failed\n");    exit (1);  }	//nflows=atoi(argv[2]);		while ((!feof(df1)) && (!feof(df2))) {				fscanf(df1, "%d%f\n", &nodes, &good1);				fscanf(df2, "%d%f\n", &nodes, &good2);		ratio = ((good1 / good2) - 1.0) * 100;		fprintf(df3,"%d\t%f\n", nodes,ratio);		//printf("nodes %d\t good1 %.3f \t good2 %.3f\t ratio %f\n", nodes, good1, good2, ratio);  }   	//printf("%f", sum/2);	  fclose(df1);  fclose(df2);  fclose(df3);}  

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?