复习内容
2016-06-15 17:59
363 查看
#include <iostream>
using namespace std;
int fac(int n)
{
int result=1;
if(n<0)
throw string("Argument cannot be negative");
else if(n>12)
throw n;
while(n)
{
result*=n;
n--;
}
return result;
}
int main( )
{
int n;
try
{
cout<<"Please input a number n to xalculte n!:";
cin>>n;
cout<<n<<"!="<<fac(n)<<endl;
}
catch(int)
{
cout<<"Exception occurred: Too large!"<<endl;
}
catch(string s)
{
cout<<"Exception occurred: "<<s<<endl;
}
return 0;
}
using namespace std;
int fac(int n)
{
int result=1;
if(n<0)
throw string("Argument cannot be negative");
else if(n>12)
throw n;
while(n)
{
result*=n;
n--;
}
return result;
}
int main( )
{
int n;
try
{
cout<<"Please input a number n to xalculte n!:";
cin>>n;
cout<<n<<"!="<<fac(n)<<endl;
}
catch(int)
{
cout<<"Exception occurred: Too large!"<<endl;
}
catch(string s)
{
cout<<"Exception occurred: "<<s<<endl;
}
return 0;
}
相关文章推荐
- 单点登录原理
- 推荐 10 款基于 Bootstrap 框架的扩展
- zabbix安装及配置
- Swift定义一个全局变量字符串
- 基于pycharm的python开发配置
- 转载:X264学习总结
- Android项目创建欢迎页
- js中的事件委托
- :2169,2170s/\\\\/\\/g
- iOS使用高德地图趟过的坑([MAMapKit] apiKey为空,请检查key是否正确设置)
- C_C++指针指针应用详解
- spring框架学习(一)
- C# 自定义光标 WaitCursor
- mongo-connector导入数据到Elasticsearch
- PHP实现Trie树(字典树)
- 利用C++试用JSON第三方库JsonCpp
- javaweb在线预览
- Docker安装SSH【Ubuntu、CentOS】
- struts2国际化
- express 工程练习