急!!!求大神砍帮忙编写一道C++的题目,谢谢!!!
展开全部
你好,可以这样写
double CalculateBudget(double dExpense, int iYears, double dRate)
{
double dTemp = dExpense;
double dRateReal = 1 + dRate * 0.01;
for(int i = 0; i < iYears; i++)
{
dTemp = dTemp * dRateReal;
}
return dTemp;
}
调用部分
int main()
{
double dBudget, dRate;
int iYear;
printf("please input budget:");
scanf("%lf, &dBudget);
printf("please input year:");
scanf("%d, &iYear);
printf("please input inflation rate:");
scanf("%lf, &dRate);
double dResult = CalculateBudget(dBudget, iYear, dRate);
printf("The result is %lf", dResult);
return 0;
}
double CalculateBudget(double dExpense, int iYears, double dRate)
{
double dTemp = dExpense;
double dRateReal = 1 + dRate * 0.01;
for(int i = 0; i < iYears; i++)
{
dTemp = dTemp * dRateReal;
}
return dTemp;
}
调用部分
int main()
{
double dBudget, dRate;
int iYear;
printf("please input budget:");
scanf("%lf, &dBudget);
printf("please input year:");
scanf("%d, &iYear);
printf("please input inflation rate:");
scanf("%lf, &dRate);
double dResult = CalculateBudget(dBudget, iYear, dRate);
printf("The result is %lf", dResult);
return 0;
}
2015-05-23
展开全部
#include <iostream>
#define MAX 80+5
using namespace std;
int m,n;
long long return_pow_2(int i)
{
long long sum=1;
for(int j=1; j<=i; j++)
{
sum*=2;
}
return sum;
}
int main()
{
int number[MAX][MAX];
cin>>n>>m;
for(int i=0; i<n; i++)
{
for(int j=0; j<m; j++)
{
cin>>number[i][j];
}
}
long long sum=0;
long long sum_lone;
for(int i=0; i<m; i++)
{
int max_num=number[i][0];
for(int j=0; j<n; j++)
{
if(number[j][i]>max_num)
{
max_num=number[j][i];
}
}
// cout<<max_num<<"\t";
sum_lone=max_num*return_pow_2(i+1);
sum+=sum_lone;
}
cout<<sum;
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询