|
|
讓使用者輸入一個數字
能夠判斷是否為3或5的倍數
- #include<iostream>
- using namespace std ;
- int main()
- {
- int input ;
- cout << "Input Number " ;
- cin >> input ;
- if( input % 15 == 0 )
- {
- cout << input << "是3與5的倍數" ;
- }
- else if( input % 3 == 0 )
- {
- cout << input << "是3的倍數" ;
- }
- else if( input % 5 == 0 )
- {
- cout << input << "是5的倍數" ;
- }
- else
- {
- cout << input << "不是3或5的倍數" ;
- }
- system("PAUSE") ;
- return 0 ;
- }
複製代碼 |
|