フィルターのクリア

counting number of inputs

1 回表示 (過去 30 日間)
stephen aboasu
stephen aboasu 2015 年 9 月 19 日
編集済み: James Tursa 2015 年 9 月 19 日
I'm designing a game that users have to guess the number. How do I keep track the number of times the user tried.

回答 (1 件)

James Tursa
James Tursa 2015 年 9 月 19 日
編集済み: James Tursa 2015 年 9 月 19 日
Use a variable as a counter. E.g., suppose the variable name was guesses. Start with guesses=0 and then do guesses=guesses+1 for each guess. I.e.,
guesses = 0;
value = whatever;
while( true )
% insert code for user to make a guess
guess = guess + 1;
% insert check to see if guess is equal to value. If so, break out of the loop
end

カテゴリ

Help Center および File ExchangeStrategy & Logic についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by