langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
30
Task/Loops-Nested/Octave/loops-nested.octave
Normal file
30
Task/Loops-Nested/Octave/loops-nested.octave
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
function search_almost_twenty()
|
||||
% create a 100x100 matrix...
|
||||
m = unifrnd(0,20, 100,100);
|
||||
for i = 1:100
|
||||
for j = 1:100
|
||||
disp( m(i,j) )
|
||||
if ( abs(m(i,j) - 20) < 1e-2 )
|
||||
return
|
||||
endif
|
||||
endfor
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
search_almost_twenty()
|
||||
|
||||
% avoiding function, we need a control variable.
|
||||
m = unifrnd(0,20, 100,100);
|
||||
innerloopbreak = false;
|
||||
for i = 1:100
|
||||
for j = 1:100
|
||||
disp( m(i,j) )
|
||||
if ( abs(m(i,j) - 20) < 1e-2 )
|
||||
innerloopbreak = true;
|
||||
break;
|
||||
endif
|
||||
endfor
|
||||
if ( innerloopbreak )
|
||||
break;
|
||||
endif
|
||||
endfor
|
||||
Loading…
Add table
Add a link
Reference in a new issue