70,035
社区成员
发帖
与我相关
我的任务
分享#include <iostream>
using namespace std;
int main(){
int first = 0;
int second = 1;
int temp;
cout << first <<' ';
cout << second <<' ';
for(int i=0;i<10;i++){
temp = first + second;
first = second;
second = temp;
cout <<temp<<' ';
}
}
#include <iostream>
using namespace std;
int main(void)
{
int N = 0;
int first = 1;
int second = 1;
int temp;
cin >> N;
cout << "Result: " << endl;
cout << "F[1] = " << first << endl;
cout << "F[2] = " << second << endl;
for(int i = 2; i < N; i++)
{
temp = first + second;
first = second;
second = temp;
cout << "F[" << i + 1 << "] = " << temp << endl;
}
return 0;
}