解题思路:
累加;累乘
注意事项:
参考代码:
#include "stdafx.h"
int main(int argc, char* argv[])
{
int n,a=2,sum=0,product;
product=a;
printf("enter the number\n");
scanf("%d",&n);
while(n--)
{
sum+=product;//累加
product*=2;//累乘
}
printf("a=%d, sum=%d\n",a,sum);
getchar();
getchar();
return 0;
}
0.0分
0 人评分
永远的丰碑 (C语言代码)浏览:666 |
2005年春浙江省计算机等级考试二级C 编程题(3) (C语言代码)浏览:406 |
C语言训练-求s=a+aa+aaa+aaaa+aa...a的值 (C语言代码)浏览:735 |
C语言程序设计教程(第三版)课后习题10.3 (C语言代码)浏览:556 |
循环入门练习6 (C语言代码)浏览:997 |
剪刀石头布 (C语言代码)浏览:1486 |
理财计划 (C语言代码)浏览:477 |
拆分位数 (C语言代码)浏览:545 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:450 |
1074(纳闷了,答案错误,求指教)浏览:372 |