NeoYang 發表於 2007-5-4 10:07:44

倍數判斷

讓使用者輸入一個數字

能夠判斷是否為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]
查看完整版本: 倍數判斷

Checking the Pageranks