Fix formatting and improve clarity in loop examples in programming book
This commit is contained in:
41
main.typ
41
main.typ
@@ -303,16 +303,17 @@ Jest jeszcze pętla `foreach`, która w róznych jezykach ma rózna składnię,
|
||||
==== Przykład
|
||||
```cs
|
||||
Console.WriteLine("Let's count to 10.");
|
||||
for (int i = 0; i < 10; i++;)
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Console.WriteLine(i + 1);
|
||||
}
|
||||
|
||||
bool shouldQuit = false;
|
||||
while (shouldQuit) {
|
||||
Console.WriteLine("I will run until you type 'q'.")
|
||||
char response = Console.ReadLine();
|
||||
if (response == 'q') {
|
||||
while (!shouldQuit)
|
||||
{
|
||||
Console.WriteLine("I will run until you type 'q'.");
|
||||
string response = Console.ReadLine();
|
||||
if (response == "q") {
|
||||
shouldQuit = true;
|
||||
}
|
||||
}
|
||||
@@ -338,6 +339,36 @@ foreach (string product in shoppingList) {
|
||||
}
|
||||
```
|
||||
==== Rezultat
|
||||
Wynik działania powyższego kodu to:
|
||||
```
|
||||
Let's count to 10.
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
I will run until you type 'q'.
|
||||
asdsd
|
||||
I will run until you type 'q'.
|
||||
cvcv
|
||||
I will run until you type 'q'.
|
||||
asas
|
||||
I will run until you type 'q'.
|
||||
q
|
||||
Please provide your PIN: 123
|
||||
Incorrect PIN. Try again
|
||||
Please provide your PIN: 1234
|
||||
Correct PIN! Access granted.
|
||||
Your shopping list:
|
||||
- bread
|
||||
- chicken
|
||||
- butter
|
||||
```
|
||||
==== Wyjaśnienie
|
||||
==== Ćwiczenia
|
||||
=== Instrukcje skoku
|
||||
|
Reference in New Issue
Block a user