彪彪
openkore
全部博文(50)
C编程(0)
软件工具(0)
c++入门(2)
openkore(0)
2010年(38)
2009年(12)
kevin258
wsy52081
ddmumahh
vincerma
raveh
mwx1234
chen_xue
zjwmv
zpbobo11
分类: C/C++
2009-12-14 15:01:19
#include <iostream>using std::cout;using std::endl;using std::cin;int& submix(int& m,int& n){ return m>n ? n : m;}int& submax(int& m,int& n){ return m>n ? m : n;}int main() { int cont = 0; cout <<"pls enter the number of fbn "<<endl; cin >> cont; int n1 =0; int n2 =1; for(int i=1 ; i <= cont ; i++){ submix(n1,n2) = n1 + n2 ; cout <<submax(n1,n2)<<endl; }return 0;}
代码二:
#include <iostream>using std::cout;using std::endl;using std::cin;int main() { int cont = 0; cout <<"pls enter the number of fbn "<<endl; cin >> cont; int n1 =0; int n2 =1; for(int i=1 ; i <= cont ; i++){ (n1 < n2 ? n1:n2) = n1 + n2 ; cout <<(n1 > n2 ? n1:n2)<<endl; }return 0;}
上一篇:斐波纳奇数列 非递归
下一篇:switch语句的使用
登录 注册