标题:[讨论] cin中无法解除"清除缓存"内容,请高手解决.附源码
取消只看楼主
钢燃
Rank: 1
等 级:新手上路
帖 子:80
专家分:0
注 册:2005-5-19
 问题点数:0 回复次数:0 
[讨论] cin中无法解除"清除缓存"内容,请高手解决.附源码

#include <iostream> #include <cassert> using namespace std;

double add(double); double fibonacci(double);

int main() { double n; bool t=true; while(t) { t=false; cout << "Please input a integer " << endl; cin >> n; assert(n<=1000); assert(n>=0); cout << endl << "1+2+3+..............+" << n << "=" << add(n) << endl; cout << "If you want to rerun around or run a other one,please input 1 " << endl; cin >> t; }

t=true; while(t) { t=false;getchar(); cout << "Please input a integer" << endl; cin >> n; assert ( n<=50 ); assert ( n>=0 ); cout << "The " << n <<"th's faibonacci is " << fibonacci( n ) <<endl; cout << "If you want to rerun around or run a other one,please input 1 " << endl; cin >> t; } return 0; }

double add(double n) { if (n>0) return n+add(n-1); else return n; }

double fibonacci( double n ) { if ( n==1 ) return 1; if ( n==2 ) return 1; return fibonacci( n-1 ) + fibonacci( n-2 ); }

搜索更多相关主题的帖子: 缓存 cin 源码 解除 
2005-09-17 13:34



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-27914-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.230788 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved