/*請勿改動主程序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
提交
取消