#include<stdio.h>
#include<math.h>
int main()
{
int i,n;
double sum,item;
sum=0;
printf("input:n\n");
scanf("%d",&n);
for(i=0;i<=n;i++)
{
item=pow(2,i);
sum=sum+item;
}
printf("sum=%lf\n",sum);
return 0;
}
#include<stdio.h>
#include<math.h>
int main()
{
int lower,upper,month,year,loan;
double money,rate;
lower=5;upper=30;
printf("请输入贷款本金:loan\n");
scanf("%d",&loan);
printf("请输入月利率:rate\n");
scanf("%lf",&rate);
printf("还款年限\t月还款额\n");
for(year=lower;year<=upper;year++)
{
month=year*12;
money=(loan*rate*pow((1+rate),month))/(pow((1+rate),month)-1);
printf("%d\t\t%lf\n",year,money);
}
return 0;
}
#include<stdio.h>
void main()
{
int num1,num2,y1,y2,y3,y5;
double y4;
printf("请输入两个数:num1,num2\n");
scanf("%d%d",&num1,&num2);
y1=num1+num2;
y2=num1-num2;
y3=num1*num2;
y4=num1*1.0/num2;
y5=num1%num2;
printf("num1,num2和y1=%d\nnum1,num2差y2=%d\nnum1,num2积y3=%d\nnum1,num2商y4=%lf\nnum1,num2余y5=%d\n",y1,y2,y3,y4,y5);
}