How to make program keep asking input..
This is a random number guessing program and asks input from user but asks once i want it to ask until correct answer given or end it when quit command typed.
display('Ödev-1 ile oluşturduğumuz oyuna hoşgeldiniz. ')
display('Tahmininizi yaptığınızda eğer doğru ise + yanlıs ise - alacaksınız!')
display('Eğer çok sıkılırsanız veya bulamaz ve sinirlenirseniz lütfen "game over" yazınız:)')
x = 0; while( x(1) == 0 ); x = randperm(10) - 1; end x = x(1:4);
a = x(1:1); b = x(2:2); c = x(3:3); d = x(4:4);
A = [a, b, c, d,]
prompt = 'Bir tahminde bulunun lütfen.';
H = input(prompt);
e = H/1000; e = floor(e); %binler basamağı buradan çıkar. r = H - e * 1000; r = r / 100; r = floor(r); % yüzler basamağı buradan çıkar. t = H-e*1000-r*100; t = t / 10; t = floor(t); y = H-e*1000-r*100-t*10; y = y / 1 ; y = floor(y); %onlar basamağı burdan çıkar.
J = [e,r,t,y,];
A == J; g = logical([J==A]); mp= '-+'; Dogrulukorani = mp(g+1) if A==J display('Tebrikler harikasın!') break; end while Dogrulukorani ~= 1111 do A == J; g = logical([J==A]); mp= '-+'; Dogrulukorani = mp(g+1)
H=input('Şansını bir kez daha denemek istermisin:');
if A==J display('Tebrikler harikasın!') break; else end
end
Réponses (1)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!