/*请勿改动主程序main及其他给定函数中的任何内容,仅在指定函数内的花括号中填入你编写的若干语句。请编一个函数double Pdt(int n,double pp[]), 它的功能是:求出数组pp中n个数的整数部分的和,并返回此值。例如: 若输入4和11.91、23.87、35.79、40.83, 则输出109.000000,整数部分的值应小于10的16次方。*/#include <conio.h>#include <stdio.h>#include <math.h>#include <windows.h>#define M 20double Pdt( int n, double pp[] ){ }main( ){int i, m;double tt[M];system("cls");printf("\nPlease enter numbers: ");scanf("%d", &m );printf("\n enter %d numbers: ", m);for( i = 0; i < m; i++ )scanf("%lf", &tt[i] );printf( "\nThe product of their integer part is: %lf.", Pdt(m, tt) );}
1 回答
Smart猫小萌
TA贡献1911条经验 获得超7个赞
#include <conio.h>
#include <stdio.h>
#include <math.h>
#include <windows.h>
#define M 20
double Pdt( int n, double pp[] )
{
int i;
double sum = 0.0;
for(i = 0; i<n; ++i)
{
sum += (int)pp[i];
}
return sum;
}
void main()
{
int i, m;
double tt[M];
system("cls");
printf("\nPlease enter numbers: ");
scanf("%d", &m );
printf("\n enter %d numbers: ", m);
for( i = 0; i < m; i++ )
scanf("%lf", &tt[i] );
printf( "\nThe product of their integer part is: %lf.", Pdt(m, tt) );
}
添加回答
举报
0/150
提交
取消