problems in the interaction with the user
Mostra commenti meno recenti
Hi everyone the code below to ask user to guess a word 'Sol'. The user has three attempts. also has the option to withdraw typing 'Pass'. can you help me make it work?
Sol = 'aaa' %is a char variable
Try = input('insert right world you have 3 trys: ','s')
i = 0;
if strcmpi(Try,'Pass');
P = input('are you sure to esc? [Y/N].\n','s');
if P =='Y'
break;
else
continue;
end
elseif strcmpi(Try,Sol);
fprintf('correct. continue? [Y/N].\n');
if P =='N'
break;
end
else
for i = 0:2
Try = input('...mmm retry: ','s')
if strcmpi(Try,Sol)
P = input('correct. continue? [Y/N].\n','s');
if P =='N'
break;
end
break;
end
P = input('correct. continue? [Y/N].\n','s');
if P =='N'
break;
end
end
end
ps.: any suggestion to optimize the code is welcome
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Common Operations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!