Chinaunix首页 | 论坛 | 博客
  • 博客访问: 225050
  • 博文数量: 50
  • 博客积分: 1415
  • 博客等级: 上尉
  • 技术积分: 541
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-03 11:48
文章分类

全部博文(50)

文章存档

2010年(38)

2009年(12)

我的朋友

分类: 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;
}


 


阅读(869) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~