正在加载图片...
/*Compute average of an array, array subscripting version. * double table average (int a[], int n double sum =0.0;/* running total in七 / count of items * for(主=0;i<n;i++) sum + a[ili return (n ! 0)? sum /n: 0.0; /* Compute average of an array, pointer version. * double table average(int a[], int n) double sum =0.0;/* running total in七 1; / count of items * in七 ptri /* traversing pointer * ptr for(主=0;i<n;i++) I sum + *ptri ptr++i return (n ! 0)? sum /n: 0.0; PROGRAM MINGMETHDOLODGY AND SOFTWAREENGINEERING 港城市大 Copyrighto1998 Angus Wu ol Hone KonePROGRAMMING METHDOLODGY AND SOFTWARE ENGINEERING Copyright©1998 Angus Wu /*Compute average of an array, array subscripting version.*/ double table_average(int a[], int n) { double sum = 0.0; /* running total */ int i; /* count of items */ for (i = 0; i < n; i++) sum += a[i]; return (n != 0) ? sum / n : 0.0; } /* Compute average of an array, pointer version. */ double table_average(int a[], int n) { double sum = 0.0; /* running total */ int i; /* count of items */ int *ptr; /* traversing pointer */ ptr = a; for (i = 0; i < n; i++) { sum += *ptr; ptr++; } return (n != 0) ? sum / n : 0.0; }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有