while
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| while [2017/06/27 17:55] – [Python3] gg | while [2017/06/29 10:32] (current) – [Java] gg | ||
|---|---|---|---|
| Line 6: | Line 6: | ||
| ===== Bash ===== | ===== Bash ===== | ||
| + | === Das Programm === | ||
| <code bash> | <code bash> | ||
| #!/bin/bash | #!/bin/bash | ||
| Line 14: | Line 15: | ||
| let COUNTER=COUNTER+1 | let COUNTER=COUNTER+1 | ||
| done | done | ||
| + | </ | ||
| + | |||
| + | === Ausführen === | ||
| + | <code bash> | ||
| + | chmod +x while.sh # als ausführbar markiern | ||
| + | ./ | ||
| </ | </ | ||
| ===== C++ ===== | ===== C++ ===== | ||
| + | === Das Programm === | ||
| <code cpp> | <code cpp> | ||
| #include < | #include < | ||
| Line 29: | Line 37: | ||
| } | } | ||
| } | } | ||
| + | </ | ||
| + | |||
| + | === Kompilieren und Ausführen === | ||
| + | Die Datei while.cpp erstellen und so ausführen: | ||
| + | <code bash> | ||
| + | g++ -Wall -g -std=c++14 while.cpp -o while # kompilieren | ||
| + | ./ | ||
| </ | </ | ||
| Line 35: | Line 50: | ||
| using System; | using System; | ||
| - | namespace | + | namespace |
| { | { | ||
| - | class ShowIf | + | class ShowWhile |
| { | { | ||
| static void Main() | static void Main() | ||
| Line 54: | Line 69: | ||
| ===== Golang ===== | ===== Golang ===== | ||
| - | In go ist so ziemlich alles eine for Schleife. Es kommt darauf an, wie man es hin schreibt. | + | In go ist so ziemlich alles eine for Schleife. Es kommt nur darauf an, wie man es hin schreibt. |
| + | === Das Programm === | ||
| <code go> | <code go> | ||
| package main | package main | ||
| Line 73: | Line 89: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | === Ausführen === | ||
| + | [[https:// | ||
| ===== Java ===== | ===== Java ===== | ||
| + | === Das Programm === | ||
| <code java> | <code java> | ||
| public class WhileLoop { | public class WhileLoop { | ||
| Line 83: | Line 103: | ||
| while (counter < 10) { | while (counter < 10) { | ||
| System.out.println(" | System.out.println(" | ||
| - | counter++ | + | counter++; |
| } | } | ||
| } | } | ||
| + | </ | ||
| + | |||
| + | === Kompilieren und ausführen === | ||
| + | Die Datei WhileLoop.java mit obigen Inhalt erstellen und so starten | ||
| + | <code bash> | ||
| + | javac WhileLoop.java # kompilieren | ||
| + | java WhileLoop | ||
| </ | </ | ||
| ===== Javascript ===== | ===== Javascript ===== | ||
| + | === Das Programm === | ||
| <code javascript> | <code javascript> | ||
| < | < | ||
| Line 106: | Line 134: | ||
| </ | </ | ||
| </ | </ | ||
| + | |||
| + | === Ausführen === | ||
| + | Den obigen Code in die Datei while.html einfügen und im Browser öffnen | ||
| ===== Perl ===== | ===== Perl ===== | ||
| + | === Das Programm === | ||
| <code perl> | <code perl> | ||
| # | # | ||
| Line 120: | Line 152: | ||
| $counter += 1; | $counter += 1; | ||
| } | } | ||
| + | </ | ||
| + | === Ausführen === | ||
| + | Die Datei while.pl erstellen und so ausführen: | ||
| + | <code bash> | ||
| + | perl while.pl | ||
| </ | </ | ||
| ===== PHP ===== | ===== PHP ===== | ||
| + | === Das Programm === | ||
| <code php> | <code php> | ||
| <?php | <?php | ||
| Line 131: | Line 169: | ||
| while ($counter < 10) { | while ($counter < 10) { | ||
| - | echo "The counter is $counter"; | + | echo "The counter is $counter\n"; |
| + | $counter++; | ||
| } | } | ||
| + | </ | ||
| + | |||
| + | === Ausführen === | ||
| + | Die Datei while.php mit obigen Inhalt erstellen und wie folgt ausführen: | ||
| + | <code bash> | ||
| + | php while.php | ||
| </ | </ | ||
| ===== Python3 ===== | ===== Python3 ===== | ||
| + | === Das Programm === | ||
| <code python> | <code python> | ||
| # | # | ||
| Line 144: | Line 190: | ||
| print(" | print(" | ||
| counter += 1 | counter += 1 | ||
| + | </ | ||
| + | |||
| + | === Ausführen === | ||
| + | Die Datei while.py mit dem obigen Code erstellen und ausführen: | ||
| + | |||
| + | <code bash> | ||
| + | python3 while.py | ||
| </ | </ | ||
while.1498578943.txt.gz · Last modified: 2017/06/27 17:55 by gg
