找回密碼
 註冊
搜索
熱搜: 活動 交友 discuz
查看: 1445|回覆: 0

[原創] 倍數判斷

[複製鏈接]
發表於 2007-5-4 10:07:44 | 顯示全部樓層 |閲讀模式
讓使用者輸入一個數字

能夠判斷是否為3或5的倍數

  1. #include<iostream>
  2. using namespace std ;

  3. int main()
  4. {
  5.     int input ;
  6.     cout << "Input Number " ;
  7.     cin >> input ;
  8.     if( input % 15 == 0 )
  9.     {
  10.          cout << input << "是3與5的倍數" ;
  11.     }
  12.     else if( input % 3 == 0 )
  13.     {  
  14.          cout << input << "是3的倍數" ;
  15.     }
  16.     else if( input % 5 == 0 )
  17.     {  
  18.          cout << input << "是5的倍數" ;
  19.     }
  20.     else
  21.     {  
  22.          cout << input << "不是3或5的倍數" ;
  23.     }
  24.     system("PAUSE") ;
  25.     return 0 ;
  26. }
複製代碼
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Checking the Pageranks

Archiver|手機版|小黑屋|WEO

GMT+8, 2026-7-29 08:35 PM , Processed in 0.032894 second(s), 20 queries .

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

快速回復 返回頂部 返回列表