0 喜歡 0 不喜歡
2.4k 瀏覽

We need to build a program that performs this algorithm:

Step 1: Read the values a,b,c,.

Step 2: Inside the try block check the condition.

            a. if(a-b!=0) then calculate the value d=c/(a-b); and display.

            b. otherwise throw the exception.

Step 3: Catch the exception and display the appropriate message.

Step 4: Stop the program.

Example input:

5 5 8

Output:

Answer is infinite because a-b is:0

Example input 2:

5 7 8

Output:

Result is:-4

 Example input 3:

3 6 8

Output:

Result is:-2
[練習] Coding (C) - 最新提問 分類:C++ |
ID: 24895 - 從幾時開始: 無限制 - 到幾時結束: 無限制

修改於 用戶: | 2.4k 瀏覽
0 0
Notice: You may have 100% output, but your code matters!

22 個回答

0 喜歡 0 不喜歡
內容已隱藏
#include <iostream>



using namespace std;



int main()

{
**** * ** *** *** a,b,c,d;
* * * ******* ** * ******** ** *** ***
* * * ** ** ** * **** ** * * *
**** * *** *** ** * ** * * * *** * * *
** **** ** * *** * ** *
* *** ** * ** ****** *** * *** ****** ** ** * ==0)
***** *********** ******* * * ** ******** ** ** * *** *** a;
* ** * *** * * *** * ** *** * * * ** * * * = c/(a-b);
* * * *** ** ****** * * ** * ** * * ** ** * * * * *** is:"<<d;
** * ***** * * *
**** * ***** ** ** ** *** **** (int e)
** ** ** * *** * ***** * **
*** * * * * * *** * ***** * * ** ** ** ** * *** *** ** is infinite because a-b is:0";
* ** ** ***** ** * *




* ** * * * * * ** ** 0;

}
最新回答 用戶: (-298 分)
0 喜歡 0 不喜歡
內容已隱藏
#include <iostream>



using namespace std;



int main()

{
** * * * **** a,b,c,d;
* * ** * *** *** ** * ** * ** * * * ***
* * * ***** * *** **** **
* * * ** * ** * ** * ** * * ** * ** * **
* ** * *** * * * ** * *
***** * * ** ** ** **** * * **** * ** * ** ==0)
******* *** *** * *** **** ***** ** * *** ** ** * * **** ** a;
*** * * * ****** * * ***** * **** * * = c/(a-b);
*** **** ** ** ** * ** * * ** ****** **** * ** * * ** ** * * * * * is:"<<d;
* * ** * * * *** * * * * *
** * * ** * * * * * (int e)
**** * *** ** *** *
* *** * ** * * * * ****** ** ** * * **** ******** ** ** *** ** *** is infinite because a-b is:0";
*** ** * ** * * * * **




*** * * *** * ** *** 0;

}
最新回答 用戶: (-215 分)
0 喜歡 0 不喜歡
內容已隱藏
#include <iostream>



using namespace std;



int main()

{
* ** *** ** *** ** a,b,c,d;
** * * ** * * *** *** **
***** *** * * * * **** * * *
* *** *** * * * ** * * * **
** * * *** **** * * ** *
***** * ***** ******** * ** **** * * **** ==0)
* * ** *** * *** * ** ** * * ***** * ***** ** * ** ** ** **** ** a;
* ** ** *** ** *** ** ******* ***** * * * ***** * = c/(a-b);
* ** *** ** * ** ** * * * * * ** *** **** **** *** ** * * * * is:"<<d;
* * ** ** ** * *
* * * ** * * * * (int e)
*** * * * * *
* * * * *** ** * * * ** * * *** ** * * * **** * * **** ** ** is infinite because a-b is:0";
** ** * ** * * ** ***** *




* * ** ** ** * * * * * * 0;

}
最新回答 用戶: (237 分)
0 喜歡 0 不喜歡
內容已隱藏
#include <iostream>



using namespace std;



int main()

{
* *** * ** ** ***** ** a,b,c,d;
* * * * * * * * ** * *
** ** * * * * ** * ** *
** * * * *** ** ** * * *
* ** * * ***** * * * *
* * ** ** ** ** * *** * * **** ** ** ** ***** * * * * ==0)
* ** * * * * *** ** * * ** * *** * *** * ** * * * ** * *** a;
* * ** ** * ** *** * * *** * * * ** ** * = c/(a-b);
* * *** * * * * * * * ****** * * * ** * *** ** **** * is:"<<d;
** **** * **** ******* *
*** **** *** * ***** (int e)
* * * * * *** * ** *
*** ** * **** ****** * ** **** **** *** * ** * * * ********** * is infinite because a-b is:0";
**** *** * ** *** * *




*** *** * ** * * ** ** 0;

}
最新回答 用戶: (126 分)
0 喜歡 0 不喜歡
內容已隱藏
#include<iostream>

using namespace std;

int main(){
* * * * ***** a,b,c,d;
*** * *** * ** *** *** ** ** * *
*** * **** **** ******** * * *
* **** ** *** * ** * ** * *** ** * **** **
** * ** ** * * * * * * * ** * ** * * ** ** * **** * * ****** * ** is:"<<d;
**** * **** *** *** *
** **** ***** **** *** **
** * * ** * * * * ** ** * *** **** * *** * * * * *** * * ********* is infinite because a-b is:0";
** *** ** * * *** ** *** * 0;

}
最新回答 用戶: (-249 分)
0 喜歡 0 不喜歡
內容已隱藏
#include *** *** **

using * * * std;



int tryA(int a, int b, int c){
* ** * ** **** ** ** * * * * return 0;
** * *** ** * ******** * return * *

}



int * ** *
* * * ** *** N[3], i;
****** *** ** * * ** * ** i++) cin * ** * N[i];
* * * ** ** * * * ** ** ** *** ** N[1], * **
* * * ** * **** * **** * ** * **** *** *** * ****** * is infinite because a-b ** * *
** * ** ** * * ***
** ** * *** ** * *** ****** * * **** * * *** **** * * * * * ** * * * * ** ** N[1], * *** *

}
最新回答 用戶: (-368 分)
0 喜歡 0 不喜歡
內容已隱藏
#include <iostream>

using namespace std;



int main(void)

{
* ** *** **** * * ** * a,b,c;


* **** *** ** * ** * * * ****** * * ** *** * * * *


* * ** * ** * * ***
* * * ** ** ** * ** ****** *
* * * **** *** * **** **** * * * * ** *** * *** * * **** is infinite because a-b is:"<<a-b;
* ** * * * * * ** * * * **
** * * * ** *** * ** *
* ** ** *** * ** * *
** ***** *** ** * ** * * **** * ** * ***** *** * ** * * * ** ** ** * * ** ***
** * * * * * * * * *

}
最新回答 用戶: (-324 分)
0 喜歡 0 不喜歡
內容已隱藏
#include ********

using std::cin;

using std::cout;



int main()

{
*** ** * * *** * * ********* num1,num2;
**** ** ** * * * *** * ** ***** num3;
** ** * * * * ** ******** caculation;
******* * ** ** ** ** **
* *** * ** **** **** * * *


** * **** ** * * * * * * * * ** * * * * *** * num1 * * * num2 * * *** num3;
* * ** *** ** * *** ******* ** * ******* ** * - num2)==0)
*** ** * * * * ** * * ** *** * ** * * * * ***** * * *** ** * * ** * **** (num1-num2);


* * ** ** ** ** ** * * *** * ******** *** ** * * * = * ** ** * ***** * * - num2);


* * * * ** *** * * ** * * * * * * ** * * *** * * * ** * ** is:" ** ** * caculation;


** **** * * ****


* *** ** * * ** ** (int e)
* * ** * *** * ** * ** *
* * * * *** *** * ****** *** ** ***** * * ** << "Answer is infinite because a-b is:" ** * * e;
* * *** ** * ******
**** *** * * **** * *** 0;

}
最新回答 用戶: (-412 分)
0 喜歡 0 不喜歡
內容已隱藏
#include <iostream>



using namespace std;



int main()

{
* *** *** * ** ** a,b,c,d;
**** * * ** ** * * * **** * *
**** **** **** * * *********** ** *
** * ***** ** ****** *
** ** * * **** *
** * **** * ** * * ** * * * * * * * *** **** * * ==0)
* ** * ** * ** *** ***** ** * ** **** * ****** * ****** * *** *** * a;
*** * **** * *** ** ** * * ** **** = c/(a-b);
* *** * ** * ***** * **** ** * ***** * * * ** * *** * is:"<<d;
* ** * * * * * * * ***
* * ** * * * ** * * ** ** (int e)
* ***** * **** * * **
*** * **** ** * ** ***** **** ** *** ** * * * ** * ** ** * *** is infinite because a-b is:0";
* * ** ** ** * * * ** *




* ******* ** * ** * * * * * * 0;

}
最新回答 用戶: (-189 分)
0 喜歡 0 不喜歡
內容已隱藏
#include<iostream>

using namespace std;

int main()

{
* * *** ** * **** **** a, b, c;
* *** ** * **** * ** d;
* * ** * * * **** **** * * * * ** ** * ** * * ** * **
** ********** ** **** *** * ** ** *
***** ***** * * **** *
* ** ** * * **** * * ** * * ** ** ** ** * ** ** * * = c/(a-b);
* * **** ** * * ** *
** ** **** ** ** *
* * * *** * * * * *****
**** * * * ** * * * ** *** ** * * * * ** * * ** ** * ** *** * * * * is infinite because a-b is:0";
* ** * * ** ** * **
** * *********** ** ** * **
** * * ** *** ****** *
** * * ***** * ** ******* * ******* * * ** * *** *** ** is:"<<d;
* ** ** * *******
** * ** ** ** ** * * * 0;

}
最新回答 用戶: (-367 分)
Welcome to Peer-Interaction Programming Learning System (PIPLS) LTLab, National DongHwa University
English 中文 Tiếng Việt
IP:172.70.179.217
©2016-2025

相關問題

0 喜歡 0 不喜歡
27 回答
[練習] Coding (C++) - 最新提問 6月 8, 2017 分類:C++ |
ID: 24896 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 3.3k 瀏覽
0 喜歡 0 不喜歡
17 回答
[練習] Coding (C) - 最新提問 6月 1, 2017 分類:C++ |
ID: 24855 - 從幾時開始: 無限制 - 到幾時結束: 無限制
| 2k 瀏覽
12,783 問題
183,442 回答
172,219 留言
4,824 用戶