⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 average1.c

📁 vc的源代码程序的基于最小特征向量的元素的集合方法的程序源代码
💻 C
字号:
/*************************************************************************//*                                                                       *//*        Average results for training and test sets                     *//*        ------------------------------------------                     *//*                                                                       *//*        This is a generic program that averages any numbers found on   *//*        a set of lines of the same pattern.                            *//*                                                                       *//*************************************************************************/#include <stdio.h>#define MAXLINE    200        /* max line length */#define MAXVALS    300       /* max values to be averaged */main(){	char Line[MAXLINE], *p1, *p2;	int Numbers=0, Lines=0, i, TrainTest;	float Val, Sum[MAXVALS];	double strtod();	for ( i = 0 ; i < MAXVALS ; i++ )		Sum[i] = 0;	while ( fgets(Line, MAXLINE, stdin) )	{		i = 0;/*		printf("%s", Line); */		/*  Count the numbers appearing on the line  */		for ( p1 = Line ; *p1 != '\n' ; p1++ )		{			if ( *p1 < '0' || *p1 > '9' ) continue;			Val = strtod(p1, &p2);			Sum[i++] += Val;			p1 = p2-1;		}		/*  The number of numbers must match any previous lines  */		if ( Lines )		{			if ( i != Numbers ) exit(1);		}		else		{			Numbers = i;		}		Lines++;	}/*	putchar('\n');*/	{		i = 0;		for ( p1 = Line ; *p1 != '\n' ; p1++ )		{			if ( *p1 < '0' || *p1 > '9' )			{				putchar(*p1);			}			else			{				printf("%.2g", Sum[i++] / Lines);				strtod(p1, &p2);				p1 = p2-1;			}		}		putchar('\n');	}}

⌨️ 快捷键说明

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