fibonaci.cpp
来自「在c环境下的对数据结构进行讲解,包含有例题及答案」· C++ 代码 · 共 22 行
CPP
22 行
//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 + =
减小字号Ctrl + -
显示快捷键?