请问这个c语言编程题怎么做?
如题所述
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a=1,b=1,r=0,sum=2;
for(int i=0;i<18;i++)
{
r=a+b;
sum+=r;
if(i%2==0)
a=r;
else
b=r;
}
printf("sum=%d",sum);
}
![](https://video.ask-data.xyz/img.php?b=https://iknow-pic.cdn.bcebos.com/1e30e924b899a90121c6ce4a0d950a7b0308f5df?x-bce-process=image%2Fresize%2Cm_lfit%2Cw_600%2Ch_800%2Climit_1%2Fquality%2Cq_85%2Fformat%2Cf_auto)
温馨提示:答案为网友推荐,仅供参考
相似回答
c语言这道题怎么做答:我写这个,修改常量可以实现任意长度数组间任意长度降序排列。include <stdio.h>#define maxlen 10//数组总长度#define midlen 8//中间需要排序的长度,修改时确保midlen小于等于maxlen 并且 maxlen-midlen为偶数或0int main(){ int a[maxlen]={3,6,1,7,8,4,9,5,10,2},i,*pb=&a[(...