June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -16,6 +16,23 @@ Specifically print out the following pattern by using one for loop nested in ano
*****</pre>
;Related tasks:
* &nbsp; [[Loop over multiple arrays simultaneously]]
* &nbsp; [[Loops/Break]]
* &nbsp; [[Loops/Continue]]
* &nbsp; [[Loops/Do-while]]
* &nbsp; [[Loops/Downward for]]
* &nbsp; [[Loops/For]]
* &nbsp; [[Loops/For with a specified step]]
* &nbsp; [[Loops/Foreach]]
* &nbsp; [[Loops/Increment loop index within loop body]]
* &nbsp; [[Loops/Infinite]]
* &nbsp; [[Loops/N plus one half]]
* &nbsp; [[Loops/Nested]]
* &nbsp; [[Loops/While]]
<br><br>
;Reference:
* [[wp:For loop|For loop]] Wikipedia.
<br><br>

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View 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

View file

@ -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');
}

View 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

View file

@ -0,0 +1,2 @@
foreach (range(1, 5) as $i)
echo str_repeat('*', $i) , PHP_EOL;

View file

@ -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";

View file

@ -1 +1 @@
print ('*' x $_ . "\n") for 1..5
print ('*' x $_ . "\n") for 1..5;

View file

@ -0,0 +1 @@
map {print '*' x $_ . "\n"} 1..5;

View file

@ -0,0 +1 @@
print('\n'.join('*' * i for i in range(1, 6)))

View file

@ -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!();
}
}

View file

@ -0,0 +1,4 @@
for (i=1; i<=5; i++) {
for (j=1; j<=i; j++) printf("*")
printf("\n")
}