Skip to content

Commit

Permalink
Update ex5_23.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooophy committed Jun 21, 2015
1 parent 3bf7ac0 commit 2fc74be
Showing 1 changed file with 6 additions and 23 deletions.
29 changes: 6 additions & 23 deletions ch05/ex5_23.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,13 @@
#include <iostream>
#include <string>
#include<stdexcept>
using std::string;
using std::cin;
using std::cout;
using std::endl;


int main () {
int a=0, b=0;
cout<<"Please input two integers: ";
while (cin>>a>>b) {
try{
if (b==0) {
throw std::runtime_error("One of the two integers is 0.");}
cout<<static_cast <double>(a)/b<<endl;
}
catch (std::runtime_error err)
{cout<<err.what();
cout<<"\nDo you want to try it again? Yes or No\n";
string a={};
cin>>a;
if (a.empty()||a[0]=='N') {
break;
}
}
}
int main()
{
int i, j;
cin >> i >> j;
cout << i / j << endl;

return 0;
}

0 comments on commit 2fc74be

Please sign in to comment.