亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

編一個函數double Pdt(int n,double pp[])

編一個函數double Pdt(int n,double pp[])

一只甜甜圈 2021-12-31 19:15:09
/*請勿改動主程序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) );
}

 


查看完整回答
反對 回復 2022-01-03
  • 1 回答
  • 0 關注
  • 742 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號