📄 more.cpp
字号:
#include<iostream>
using namespace std;
bool fibon_elem(int a,int &b)
{
if(a<=0||a>1024)
{
b=0;
return false;
}
b=1;
int n_2=1,n_1=1;
for(int ix=3;ix<=a;++ix)
{
b=n_2+n_1;
n_2=n_1;
n_1=b;
}
return true;
}
int main()
{
int pos,elem;
char ch;
bool more=true;
while(more)
{
cout << "Please enter a position : ";
cin >> pos;
if(fibon_elem(pos,elem))
cout << " elements # "<< pos << " is "<< elem << endl;
else
cout << "Sorry! Couldn't calculate element # " << pos << endl;
cout <<"Would you like to try again?(y/n) ";
cin >> ch;
if(ch != 'y' && ch != 'Y')
more = false;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -