這個代碼為什么在電腦上演示最后的結(jié)果是空白呢
如題 ?這個程序為什么在電腦的結(jié)果是空白
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
/**
?* 定義函數(shù)division
?* 參數(shù)整型dividend、整型divisor
?*/
int division(int dividend, int divisor)
{
? ? if(0 == divisor)
{
? ? ? ? // 拋出異常,字符串“除數(shù)不能為0”
throw string("除數(shù)不能為0");
}
else
{
return dividend / divisor;
}
}
int main(void)
{
int d1 = 0;
int d2 = 0;
int r = 0;
cin >> d1;
cin >> d2;
? ??
try
? ? {
? ? ? ?r= division(d1,d2);
? ? ? ?cout<<r<<endl;
? ? }
? ? catch(string &str)
? ? {
? ? ? ? cout<<str<<endl;
? ? }
return 0;
}
2016-11-07
2016-11-07
輸入d1,d2試試