你好,可以这样写
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;
}
#include
#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{
for(int j=0; j{
cin>>number[i][j];
}
}
long long sum=0;
long long sum_lone;
for(int i=0; i{
int max_num=number[i][0];
for(int j=0; j{
if(number[j][i]>max_num)
{
max_num=number[j][i];
}
}
// cout<sum_lone=max_num*return_pow_2(i+1);
sum+=sum_lone;
}
cout<return 0;
}