Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- % Set a flag to determine if the user is cheating
- isCheating = false;
- % Define a function to check if the user is cheating
- function checkForCheats(input)
- % Set a list of cheats
- cheats = {'cheat1', 'cheat2', 'cheat3'};
- % Iterate through the list of cheats
- for i = 1:length(cheats)
- % If the input contains a cheat, set the flag to true and break out of the loop
- if ~isempty(strfind(input, cheats{i}))
- isCheating = true;
- break;
- end
- end
- end
- % Prompt the user for input
- input = input('Enter a command: ', 's');
- % Check if the user is cheating
- checkForCheats(input);
- % If the user is cheating, display a message and exit the program
- if isCheating
- disp('Cheating is not allowed!');
- return;
- end
- % If the user is not cheating, continue with the program
- disp('Valid input');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement