倍數判斷
讓使用者輸入一個數字能夠判斷是否為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 ;
}
頁:
[1]

