a003: 兩光法師占卜術

2022.11.01 PM 10:00 by CBJ

來源 : https://zerojudge.tw/ShowProblem?problemid=a003
出題者 : Zerojudge
標籤 : 運算式、條件判斷
難易度 : 0.1
解題想法 : 將輸入的兩個數字計算後判斷並輸出對應結果
//C language
//solution link(含註解): https://github.com/CBJ0519/CBJsProgramDiary.com/blob/main/zj/a003.c

#include <stdio.h>
int main()
{
    int M,D;
    scanf("%d%d",&M,&D); 
    int S=(M*2+D)%3;  
    switch(S){   
        case 0:{  
            printf("普通\n");
        }
        break;
        case 1:{  
            printf("吉\n");
        }
        break;
        case 2:{  
            printf("大吉\n");
        }
        break;
    }
    return 0;
}
//C++ language
//solution link(含註解): https://github.com/CBJ0519/CBJsProgramDiary.com/blob/main/zj/a003.cpp

#include <iostream>
using namespace std;
int main()
{
    int M,D;
    cin>>M>>D;  
    int S=(M*2+D)%3;  
    if(S){  
        if(S==1) cout<<"吉\n"; 
        else cout<<"大吉\n"; 
    }
    else cout<<"普通\n"; 
    return 0;
}
## Python language
## solution link(含註解): https://github.com/CBJ0519/CBJsProgramDiary.com/blob/main/zj/a003.py

M,D=map(int,input().split()) 
S=((M*2)+D)%3
if S==0: print('普通')
elif S==1: print('吉') 
else: print('大吉')

相關文章

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *