水题感想
来源:互联网 发布:怎样成为一个网络写手 编辑:程序博客网 时间:2024/06/06 18:33
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
int main()
{
int a[100]={1,1},i=2,n;
scanf("%d",&n);
for(i=2;i<100;i++)
{
a[i]=a[i-1]+a[i-2];
}
{
int a[100]={1,1},i=2,n;
scanf("%d",&n);
for(i=2;i<100;i++)
{
a[i]=a[i-1]+a[i-2];
}
printf("%d\n",a[n-1]);
return 0;
}
}
n-1换成i就不对了,为什么,因为跑完for循环i=n,所以应为i-1
一定要小心变量的值时刻在变,最好还是利用不变的值
阅读全文
0 0
- 水题感想
- 水题感想系列
- 一道水题的感想
- 一周水题之后的感想
- Google2012笔试题感想
- UVA100题感想
- 200题感想
- leetcode刷题感想
- 感想
- 感想!
- 感想
- 感想
- 感想
- 感想!
- 感想
- 感想
- 感想
- 感想
- Android框架之MVP实践简单万花筒
- HTML5权威指南笔记:22-设置文本样式
- 月旦评 20171020
- redis安装
- Next Permutation:已知某个排列求下个排列
- 水题感想
- django redis缓存
- UVA 1279
- 第八天(php循环与数组)
- 《推荐系统实践》要点思维导图
- IaaS、PaaS、SaaS区别举例
- set容器的一些用法
- C语言输出最大值最小值
- 服务注册与发现以及Zookeeper的引入