#include<iostream>
using namespace std;
int min(int a,int b)
{
if(a>b)
throw a;
return a;
}
int main()
{
int a,b,c;
try
{
c=min(3,2);
cout<<c<<endl;
}
catch(int)
{
cout<<"error 1"<<endl;
}
return 0;
}
try catch 使用
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
數據結構——數組(1)數組求和&打印二維數組&判斷數組是否遞增
數組求和 方法一:直接一次for循環 int GetSum1(int *a,int n) { int sum=0; for (int i=0; i<n;i++) { sum+=a[i];