📄 fibonaci.cpp
字号:
//fibonaci.cpp
#include <iostream.h> //cout
#include <conio.h> //getc()
#include <limits.h> //UINT_MAX =4294967295
void main()
{ unsigned int first,second;
short count=1;
first=0; //第一数为0
second=1; //第二数开始为1
cout << 0 << " ";
while (first < ULONG_MAX/2) //第一数需小于最大值之一半
{ cout << second << " ";
count++;
unsigned int third = first + second; //第三数=第一数加第二数
first = second; //第二数变第一数
second = third; //第三数变第二数
}
cout <<"\n共有: " << count << " 项\n";
getch(); //暂停
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -