June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -16,6 +16,23 @@ Specifically print out the following pattern by using one for loop nested in ano
|
|||
*****</pre>
|
||||
|
||||
|
||||
;Related tasks:
|
||||
* [[Loop over multiple arrays simultaneously]]
|
||||
* [[Loops/Break]]
|
||||
* [[Loops/Continue]]
|
||||
* [[Loops/Do-while]]
|
||||
* [[Loops/Downward for]]
|
||||
* [[Loops/For]]
|
||||
* [[Loops/For with a specified step]]
|
||||
* [[Loops/Foreach]]
|
||||
* [[Loops/Increment loop index within loop body]]
|
||||
* [[Loops/Infinite]]
|
||||
* [[Loops/N plus one half]]
|
||||
* [[Loops/Nested]]
|
||||
* [[Loops/While]]
|
||||
<br><br>
|
||||
|
||||
|
||||
;Reference:
|
||||
* [[wp:For loop|For loop]] Wikipedia.
|
||||
<br><br>
|
||||
|
|
|
|||
|
|
@ -1,11 +1,6 @@
|
|||
If OpenConsole()
|
||||
Define i, j
|
||||
For i=1 To 5
|
||||
For j=1 To i
|
||||
Print("*")
|
||||
Next j
|
||||
PrintN("")
|
||||
Next i
|
||||
Print(#LFCR$+"Press ENTER to quit"): Input()
|
||||
CloseConsole()
|
||||
EndIf
|
||||
For i = 1 TO 5
|
||||
For j = 1 To i
|
||||
TextWindow.Write("*")
|
||||
EndFor
|
||||
TextWindow.WriteLine("")
|
||||
EndFor
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
FOR i = 1 TO 5
|
||||
FOR j = 1 TO i
|
||||
PRINT "*";
|
||||
NEXT j
|
||||
PRINT
|
||||
NEXT i
|
||||
If OpenConsole()
|
||||
Define i, j
|
||||
For i=1 To 5
|
||||
For j=1 To i
|
||||
Print("*")
|
||||
Next j
|
||||
PrintN("")
|
||||
Next i
|
||||
Print(#LFCR$+"Press ENTER to quit"): Input()
|
||||
CloseConsole()
|
||||
EndIf
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
for n = 1 to 5
|
||||
for m = 1 to n
|
||||
print "*";
|
||||
next m
|
||||
print
|
||||
next n
|
||||
FOR i = 1 TO 5
|
||||
FOR j = 1 TO i
|
||||
PRINT "*";
|
||||
NEXT j
|
||||
PRINT
|
||||
NEXT i
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
Public OutConsole As Scripting.TextStream
|
||||
For i = 0 To 4
|
||||
For j = 0 To i
|
||||
OutConsole.Write "*"
|
||||
Next j
|
||||
OutConsole.WriteLine
|
||||
Next i
|
||||
for n = 1 to 5
|
||||
for m = 1 to n
|
||||
print "*";
|
||||
next m
|
||||
print
|
||||
next n
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
For x As Integer = 0 To 4
|
||||
For y As Integer = 0 To x
|
||||
Console.Write("*")
|
||||
Next
|
||||
Console.WriteLine()
|
||||
Next
|
||||
Public OutConsole As Scripting.TextStream
|
||||
For i = 0 To 4
|
||||
For j = 0 To i
|
||||
OutConsole.Write "*"
|
||||
Next j
|
||||
OutConsole.WriteLine
|
||||
Next i
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
10 FOR i = 1 TO 5
|
||||
20 FOR j = 1 TO i
|
||||
30 PRINT "*";
|
||||
40 NEXT j
|
||||
50 PRINT
|
||||
60 NEXT i
|
||||
For x As Integer = 0 To 4
|
||||
For y As Integer = 0 To x
|
||||
Console.Write("*")
|
||||
Next
|
||||
Console.WriteLine()
|
||||
Next
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
10 FOR I = 1 TO 5
|
||||
20 FOR J = 1 TO I
|
||||
10 FOR i = 1 TO 5
|
||||
20 FOR j = 1 TO i
|
||||
30 PRINT "*";
|
||||
40 NEXT
|
||||
40 NEXT j
|
||||
50 PRINT
|
||||
60 NEXT
|
||||
60 NEXT i
|
||||
|
|
|
|||
6
Task/Loops-For/BASIC/loops-for-17.basic
Normal file
6
Task/Loops-For/BASIC/loops-for-17.basic
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
10 FOR I = 1 TO 5
|
||||
20 FOR J = 1 TO I
|
||||
30 PRINT "*";
|
||||
40 NEXT
|
||||
50 PRINT
|
||||
60 NEXT
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
for(int i = 1; i <= 5; ++i) {
|
||||
for(int j = 1; j <= i; j++)
|
||||
std::cout << "*";
|
||||
std::cout << std::endl;
|
||||
for(int i = 0; i < 5; ++i) {
|
||||
for(int j = 0; j < i; ++j)
|
||||
std::cout.put('*');
|
||||
|
||||
std::cout.put('\n');
|
||||
}
|
||||
|
|
|
|||
10
Task/Loops-For/Klong/loops-for.klong
Normal file
10
Task/Loops-For/Klong/loops-for.klong
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
:" x{p}:*y means repeat {p} x times starting at y "
|
||||
|
||||
5{x{.d(0c*);x}:*0;.p("");x+1}:*1
|
||||
|
||||
:" But you would not do it like this! "
|
||||
:" You would reshape 0c* to the desired length "
|
||||
:" in a function and then iterate that function "
|
||||
:" over a vector of numbers: "
|
||||
|
||||
{.p(x:^0c*)}'1+!5
|
||||
2
Task/Loops-For/PHP/loops-for-3.php
Normal file
2
Task/Loops-For/PHP/loops-for-3.php
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
foreach (range(1, 5) as $i)
|
||||
echo str_repeat('*', $i) , PHP_EOL;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
for ($x = 1; $x <= 5; $x++) {
|
||||
for ($y = 1; $y <= $x; $y++) {
|
||||
for(my $x = 1; $x <= 5; $x++) {
|
||||
for(my $y = 1; $y <= $x; $y++) {
|
||||
print "*";
|
||||
}
|
||||
print "\n";
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
print ('*' x $_ . "\n") for 1..5
|
||||
print ('*' x $_ . "\n") for 1..5;
|
||||
|
|
|
|||
1
Task/Loops-For/Perl/loops-for-4.pl
Normal file
1
Task/Loops-For/Perl/loops-for-4.pl
Normal file
|
|
@ -0,0 +1 @@
|
|||
map {print '*' x $_ . "\n"} 1..5;
|
||||
1
Task/Loops-For/Python/loops-for-3.py
Normal file
1
Task/Loops-For/Python/loops-for-3.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
print('\n'.join('*' * i for i in range(1, 6)))
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
for i in 0..5 {
|
||||
for _ in 0..(i + 1) {
|
||||
print!("*");
|
||||
}
|
||||
fn main() {
|
||||
for i in 0..5 {
|
||||
for _ in 0..(i + 1) {
|
||||
print!("*");
|
||||
}
|
||||
|
||||
print!("\n");
|
||||
println!();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
4
Task/Loops-For/Stata/loops-for-2.stata
Normal file
4
Task/Loops-For/Stata/loops-for-2.stata
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
for (i=1; i<=5; i++) {
|
||||
for (j=1; j<=i; j++) printf("*")
|
||||
printf("\n")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue