Re: [問卦] 用if else敘述反對死刑但這個必須死

作者: applebg (數學不及格)   2022-08-23 13:38:29
※ 引述《pchion2002 (阿我就怕被罵阿)》之銘言:
: 各位大師下午好
: 昨天兩名警察領了盒飯
: 造就了有金句產生
: 從程式語言來看下面這句話
: 「我反對死刑但這一定要判死」
: 判斷式要怎麼寫才能成立?
//judges do not sentence people to death
bool death_sentence = False;
//assume that no policemen die
bool kill_policemen = False;
//if no policemen die, the judge would say the following
while(!death_sentence){
printf("judge: be a good person, you shall be pardoned");
//if a policeman dies, the judge will stop pardoning people
//and sentence people to death
if(kill_policemen == True){
printf("May God have mercy upon your soul,
because I won't!");
death_sentence = True;
break;
}
}

Links booklink

Contact Us: admin [ a t ] ucptt.com