,直到我想編寫一個if語句,將繼續重複一個問題,直到滿足特定條件重複在函數中前行的if語句滿足
事情是這樣的:
fun<-function(){
x<-readline("what is x? ")
if(x>5)
{print("X must be less than 5")
**repeat lines 3 & 4**
}else{
print("Correct")}
}
對不起** - 但我不確定如何正確寫入該行。我期望做的是在每次輸入大於5的數字時重複提示「什麼是x」,直到給出小於5的數字。理論上這個函數看起來像這樣
fun()
what is x? 6
X must be less than 5
what is x? 8
X must be less than 5
what is x? 3
Correct
'while'這樣做。 – Justin