Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [ output_args ] = losuj( param )
- %UNTITLED2 Summary of this function goes here
- % Detailed explanation goes here
- x = randi(10, 1, param);
- y = randi(10, 1, param);
- z = randi(3, 1, param);
- if (param == 1)
- if (z == 1)
- sprintf('ile sie rowna %d + %d?', x, y)
- a = input('')
- if (a == x + y)
- sprintf('ok')
- losuj(param + 1)
- else
- sprintf('zle')
- error(' ')
- end
- elseif (z == 2)
- sprintf('ile sie rowna %d - %d?', x, y)
- b = input('')
- if (b == x - y)
- sprintf('ok')
- losuj(param + 1)
- else
- sprintf('zle')
- error(' ')
- end
- else
- sprintf('ile sie rowna %d * %d?', x, y)
- c = input('')
- if (c == x * y)
- sprintf('ok')
- losuj(param + 1)
- else
- sprintf('zle')
- error(' ')
- end
- end
- else
- sprintf('%d %d %d', x, y, z)
- q = ' ';
- for i = 1:param
- q + num2str(x(1,i));
- if (z(1,i) == 1)
- q + '+';
- elseif (z(1, i) == 2)
- q + '-';
- else
- q + '*';
- end
- q + num2str(y(1,i));
- i = i + 1;
- end
- sprintf('%s', q)
- end
- liczby = randi(10, 1, param + 1)
- znaki = radni(3, 1, param)
- znak = [+, -, *]
- s = num2str(liczby(1))
- for i = 1:randi
- s = [s, znak(znaki(i)), liczby(i)]
Add Comment
Please, Sign In to add comment