Compilation Error !!!!

木可大大 2008-10-15 05:32:11
There are many students in PHT School. One day, the headmaster whose name is PigHeader wanted all students stand in a line. He prescribed that girl can not be in single. In other words, either no girl in the queue or more than one girl stands side by side. The case n=4 (n is the number of children) is like
FFFF, FFFM, MFFF, FFMM, MFFM, MMFF, MMMM
Here F stands for a girl and M stands for a boy. The total number of queue satisfied the headmaster’s needs is 7. Can you make a program to find the total number of queue with n children?

Input
There are multiple cases in this problem and ended by the EOF. In each case, there is only one integer n means the number of children (1<=n<=1000)
Output
For each test case, there is only one integer means the number of queue satisfied the headmaster’s needs.
Sample Input
1
2
3

Sample Output
1
2
4
我的代码是
#include<iostream>
using namespace std;
int main()
{
int a[1000],i;
while(scanf("%d",a)!=EOF)
{
int a[0]=1, a[1]=1,a[2]=2,a[3]=4;
for(i=4;i<1001;i++)
{
a[i]=a[i-1]+a[i-2]+a[i-4];
}
cout<<a[i]<<endl;
}
return 0;
} Compilation Error
那里错了
...全文
192 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
机智的呆呆 2008-10-15
  • 打赏
  • 举报
回复
首先 c和c++的流同时使用时 要用iso::sync_with_stdio();
我这没编译器,其他的期待高手~~~

64,649

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧