※ 引述《lfst (渾然天成NNNN )》之銘言:
: #include<stdio.h>
: int main()
Please DO NOT post your code here -- it will not help others in learning
this subject, but I do encourage the following question.
: }
: 目前跑的好像還ok 可是
: if(head<=0|| leg<=0 ||tail<0)
: 為什麼不能改成if((head||leg<=0)||(tail<0))呢?
: 還有
: if(rabbits<0||chicken<0||crabs<0)
: 為什麼不能改成if(rabbits||chicken||crabs<0)呢?
We have not yet taught the "||" operator. What you want to describe here
is that when "rabbit is smaller than 0", or "chicken is smaller than 0",
or "crab is smaller than 0", then you want to do something.
When you write (rabbits||chicken||crabs<0), it means
( (rabit) || (chicken) || (crab < 0))
Unlike in English, in C the "< 0" part will not automatically be inserted
into (rabit) and (chicken).
More in class.
--
台灣大學資訊工程系 劉邦鋒
--------------------------
合理的作業是訓練,不合理的作業是磨練。
--
※ 發信站: 批踢踢實業坊(ptt.csie.ntu.edu.tw)
◆ From: 140.112.28.27