From 523a6ab9206740a958bce93145c4661cca5fc8f0 Mon Sep 17 00:00:00 2001 From: Peter Gerwinski <peter.gerwinski@hs-bochum.de> Date: Thu, 20 Jun 2024 19:10:49 +0200 Subject: [PATCH] Notizen und Beispiele 20.6.2024 --- 20240620/ad-20240620.txt | 126 ++++++++++++ 20240620/bewert.pas | 396 ++++++++++++++++++++++++++++++++++++++ 20240620/const-01.c | 11 ++ 20240620/const-01.cpp | 11 ++ 20240620/const-02.c | 19 ++ 20240620/const-03.c | 20 ++ 20240620/const-04.c | 20 ++ 20240620/functions-01.cpp | 18 ++ 20240620/functions-02.cpp | 18 ++ 20240620/functions-03.cpp | 18 ++ 20240620/functions-04.cpp | 19 ++ 20240620/functions-05.cpp | 19 ++ 20240620/functions-05.s | 65 +++++++ 20240620/functions-06.cpp | 9 + 20240620/functions-07.cpp | 9 + 20240620/functions-07.s | 30 +++ 20240620/functions-08.cpp | 9 + 20240620/functions-08.s | 30 +++ 20240620/hello-01.cpp | 7 + 20240620/hello-02.cpp | 7 + 20240620/hello-03.cpp | 7 + 20240620/hello-04.cpp | 7 + 20240620/mem-01.c | 17 ++ 20240620/mem-02.c | 17 ++ 20240620/mem-03.c | 10 + 20240620/operators-01.cpp | 21 ++ 20240620/operators-01.s | 78 ++++++++ 20240620/operators-02.cpp | 20 ++ 20240620/operators-03.cpp | 20 ++ 20240620/operators-04.cpp | 20 ++ 20240620/printlib-01.c | 11 ++ 20240620/printlib-01.h | 2 + 20240620/printlib-02.c | 11 ++ 20240620/printlib-03.cpp | 11 ++ 20240620/printlib-04.cpp | 12 ++ 20240620/printlib-05.c | 11 ++ 20240620/printlib-05.h | 2 + 20240620/printlib-06.h | 5 + 20240620/references-01.c | 14 ++ 20240620/references-02.c | 14 ++ 20240620/void-01.c | 7 + 20240620/void-02.c | 7 + 20240620/void-03.c | 12 ++ 20240620/void-04.c | 12 ++ 20240620/void-05.c | 12 ++ 20240620/void-06.c | 13 ++ 20240620/void-07.c | 13 ++ 20240620/void-08.c | 14 ++ 20240620/void-09.c | 14 ++ 20240620/void-10.c | 14 ++ 20240620/void-11.c | 13 ++ 20240620/void-12.c | 13 ++ 52 files changed, 1315 insertions(+) create mode 100644 20240620/ad-20240620.txt create mode 100644 20240620/bewert.pas create mode 100644 20240620/const-01.c create mode 100644 20240620/const-01.cpp create mode 100644 20240620/const-02.c create mode 100644 20240620/const-03.c create mode 100644 20240620/const-04.c create mode 100644 20240620/functions-01.cpp create mode 100644 20240620/functions-02.cpp create mode 100644 20240620/functions-03.cpp create mode 100644 20240620/functions-04.cpp create mode 100644 20240620/functions-05.cpp create mode 100644 20240620/functions-05.s create mode 100644 20240620/functions-06.cpp create mode 100644 20240620/functions-07.cpp create mode 100644 20240620/functions-07.s create mode 100644 20240620/functions-08.cpp create mode 100644 20240620/functions-08.s create mode 100644 20240620/hello-01.cpp create mode 100644 20240620/hello-02.cpp create mode 100644 20240620/hello-03.cpp create mode 100644 20240620/hello-04.cpp create mode 100644 20240620/mem-01.c create mode 100644 20240620/mem-02.c create mode 100644 20240620/mem-03.c create mode 100644 20240620/operators-01.cpp create mode 100644 20240620/operators-01.s create mode 100644 20240620/operators-02.cpp create mode 100644 20240620/operators-03.cpp create mode 100644 20240620/operators-04.cpp create mode 100644 20240620/printlib-01.c create mode 100644 20240620/printlib-01.h create mode 100644 20240620/printlib-02.c create mode 100644 20240620/printlib-03.cpp create mode 100644 20240620/printlib-04.cpp create mode 100644 20240620/printlib-05.c create mode 100644 20240620/printlib-05.h create mode 100644 20240620/printlib-06.h create mode 100644 20240620/references-01.c create mode 100644 20240620/references-02.c create mode 100644 20240620/void-01.c create mode 100644 20240620/void-02.c create mode 100644 20240620/void-03.c create mode 100644 20240620/void-04.c create mode 100644 20240620/void-05.c create mode 100644 20240620/void-06.c create mode 100644 20240620/void-07.c create mode 100644 20240620/void-08.c create mode 100644 20240620/void-09.c create mode 100644 20240620/void-10.c create mode 100644 20240620/void-11.c create mode 100644 20240620/void-12.c diff --git a/20240620/ad-20240620.txt b/20240620/ad-20240620.txt new file mode 100644 index 0000000..2ed1ef3 --- /dev/null +++ b/20240620/ad-20240620.txt @@ -0,0 +1,126 @@ +Dies +ein +ist +Test. + +2 + 2 = 4 + +Shell-Skript "eq": + + #!/bin/bash + while read line; do + echo -n "$line = " + echo "$line" | bc -l + done + +Aufaddieren: "Pipen" durch selbstgeschriebenes Programm "sumup" + + 2.50 + 13.70 + 1.20 + 9.80 + ------ + 27.20 + +Bewertung von Klausuren: "Pipen" durch selbstgeschriebenes Programm "bewert" +~~~~~~~~~~~~~~~~~~~~~~~ +v = P # vollständig richtig +ü = P # vollständig richtig, zusätzlich was Überflüssiges +u = P # vollständig richtig, zusätzlich was Falsches ++ = P # übererfüllt +* = P + 1 # deutlich übererfüllt (Zusatzpunkt) +g = P # mit gutem Willen richtig +G = P - 1 # mit viel gutem Willen richtig (Punktabzug) +o = P # originelle, richtige Lösung +O = P - 1 # originelle, fast richtige Lösung (Punktabzug) +: = 0 # netter Versuch, nett erzählt +. = 0 # netter Versuch +° = 0 # völlig falsch; würde negative Punkte rechtfertigen +0 = 0 # nicht bearbeitet +3 = P * 0.75 # weitgehend richtig (3/4 der Punktzahl) +2 = P * 0.49 # ungefährt zur Hälfte richtig (halbe Punktzahl) +1 = P * 0.25 # Richtung stimmt (1/4 der Punktzahl) +? = 0 # Platzhalter für "merkwürdige Lösung - noch mal draufgucken" +! = 0 # Platzhalter für "siehe Datenträger" + +k @ 1.a = P - 1 # Korrektur richtig, Erklärung falsch +s @ 1.b = P - 1 # temporärer Speicherplatz falsch deklariert, ansonsten richtig +S @ 1.b = P - 1 # temporärer Speicherplatz falsch deklariert, ansonsten originell, aber richtig +h @ 1.b = P # Länge des Puffers hart codiert, aber Null-Byte korrekt mit berücksichtigt +p @ 1.b = P # Zeiger auf String-Konstante nicht korrigiert, ansonsten richtig +z @ 1.c = P - 1 # Gesamtspeicher angegeben statt zusätzlichen +t @ 1.c = 1 # Laufzeit statt Speicherbedarf ermittelt +x @ 1.c = P # O(1) unterschlagen, stattdessen strlen()-Optimierungsmöglichkeit erkannt +p @ 2.a = P # Zeiger bzw. Adresse nicht erwähnt +t @ 2.a = P - 1 # falscher Typ nicht erwähnt, ansonsten richtig +e @ 2.b = P - 1 # Endianness verwechselt, ansonsten richtig +n @ 2.b = P # Null-Symbol nicht erwähnt, ansonsten richtig +N @ 2.b = P # Null-Symbol-Lücke gesehen, aber nicht erwähnt, ansonsten richtig +x @ 2.b = P # Null-Symbol falsch begründet, ansonsten richtig +s @ 2.c = P - 1 # Endianness auf ganze Struktur angewandt, nicht nur auf einzelne Zahlen +S @ 2.c = 1 # Endianness auf ganze Struktur angewandt, gar nicht auf einzelne Zahlen +e @ 2.c = P # Endianness verwechselt (Folgefehler), ansonsten richtig +E @ 2.c = P - 1 # Endianness auf 32-Bit-Worte angewandt +n @ 2.c = P - 1 # Null-Symbol nicht beachtet, daher falsch, ansonsten richtig +n @ 2.d = P # "Auffüllen mit Nullen", ansonsten richtig +b @ 2.d = P - 2 # Begründung fehlt +h @ 3.a = P # Bibliothek "math.h" +H @ 3.a = P # Bibliothek "math.h", zusätzlich was Falsches +m @ 3.d = 2 # Objekt und Konstruktor erstellt, Ableitungs-Methode fehlt +h @ 4.x = P # Dimensionen des Bildes hart codiert --> okay, weil "4x8" vorgegeben +$ @ 4.x = P - 1 # falscher Bit-Shift für das Lesen der XBM-Datei (außerdem: pow(), eigenes Bild, teils mit 0b..., teils mit 0x...;-) +A @ 4.x = 1 # Ansatz dargelegt +a @ 4.x = 4 # netter Ansatz, dann verhaspelt +b @ 4.x = 1 # Vorschlag: "Bibliothek benutzen" +f @ 4.x = 1 # Ansatz für ein anderes Dateiformat + +>> 42 = 0.7 +>> 40 = 1.0 +>> 38 = 1.3 +>> 35 = 1.7 +>> 33 = 2.0 +>> 30 = 2.3 +>> 28 = 2.7 +>> 25 = 3.0 +>> 23 = 3.3 +>> 21 = 3.7 +>> 20 = 4.0 +>> 0 = n.b. + +@@ Aufgabe 1 1 1 1 2 2 2 2 3 3 3 3 4 +@@ Teilaufgabe a b c d a b c d a b c d x +== Punkte 2 4 2 4 2 3 3 3 1 2 3 5 8 ======== +# ----------------------------------------------------------------------- 1a b c d 2a b c d 3a b c d 4 +012345678 45 xxxxxxxxxxxxx xxxxxxxxxxxxxxx k s 1 0 v n n n v g * 0 0 22 3.7 1/2 3/4 1/2 0/4 2/2 3/3 2/3 3/3 1/1 2/2 4/3 0/5 0/8 +012345678 68 xxxxxxxxxxxxx xxxxxxxxxxxxxxx + o t 0 p + s . 0 g 0 v . 21 3.7 2/2 4/4 1/2 0/4 2/2 3/3 2/3 0/3 0/1 2/2 0/3 5/5 0/8 +012345678 81 xxxxxxxxxxxxx xxxxxxxxxxxxxxx v + v v v + * + h g g v h 43 0.7 2/2 4/4 2/2 4/4 2/2 3/3 4/3 3/3 1/1 2/2 3/3 5/5 8/8 +012345678 03 xxxxxxxxxxxxx xxxxxxxxxxxxxxx v + v v t g * * H + v v $ 42 0.7 2/2 4/4 2/2 4/4 1/2 3/3 4/3 4/3 1/1 2/2 3/3 5/5 7/8 +012345678 44 xxxxxxxxxxxxx xxxxxxxxxxxxxxx v 0 . 0 p . S 0 g : 1 0 . 7 n.b. 2/2 0/4 0/2 0/4 2/2 0/3 1/3 0/3 1/1 0/2 1/3 0/5 0/8 +012345678 09 xxxxxxxxxxxxx xxxxxxxxxxxxxxx 1 v z v v g 1 0 v . g v v 33 2.0 1/2 4/4 1/2 4/4 2/2 3/3 1/3 0/3 1/1 0/2 3/3 5/5 8/8 +012345678 63 xxxxxxxxxxxxx xxxxxxxxxxxxxxx g : 0 0 g G 1 1 g 1 v 0 b 14 n.b. 2/2 0/4 0/2 0/4 2/2 2/3 1/3 1/3 1/1 1/2 3/3 0/5 1/8 +012345678 46 xxxxxxxxxxxxx xxxxxxxxxxxxxxx : p : 0 p N n O h + g v a 28 2.7 0/2 4/4 0/2 0/4 2/2 3/3 2/3 2/3 1/1 2/2 3/3 5/5 4/8 +012345678 66 xxxxxxxxxxxxx xxxxxxxxxxxxxxx . 0 1 0 p e e * 0 G u v f 22 3.7 0/2 0/4 1/2 0/4 2/2 2/3 3/3 4/3 0/1 1/2 3/3 5/5 1/8 +012345678 90 xxxxxxxxxxxxx xxxxxxxxxxxxxxx v + * v v G 0 g h * v v a 36 1.7 2/2 4/4 3/2 4/4 2/2 2/3 0/3 3/3 1/1 3/2 3/3 5/5 4/8 +012345678 25 xxxxxxxxxxxxx xxxxxxxxxxxxxxx + s x o p v n v h * + v 1 35 1.7 2/2 3/4 2/2 4/4 2/2 3/3 2/3 3/3 1/1 3/2 3/3 5/5 2/8 +012345678 16 xxxxxxxxxxxxx xxxxxxxxxxxxxxx g v z o v e n b h g u v * 38 1.3 2/2 4/4 1/2 4/4 2/2 2/3 2/3 1/3 1/1 2/2 3/3 5/5 9/8 +012345678 58 xxxxxxxxxxxxx xxxxxxxxxxxxxxx + v z 0 p n 1 v h + + v u 35 1.7 2/2 4/4 1/2 0/4 2/2 3/3 1/3 3/3 1/1 2/2 3/3 5/5 8/8 +012345678 64 xxxxxxxxxxxxx xxxxxxxxxxxxxxx v s t 0 v e E v 0 g g m v 30 2.3 2/2 3/4 1/2 0/4 2/2 2/3 2/3 3/3 0/1 2/2 3/3 2/5 8/8 +012345678 32 xxxxxxxxxxxxx xxxxxxxxxxxxxxx 0 0 0 0 0 0 0 0 0 0 0 0 0 0 n.b. 0/2 0/4 0/2 0/4 0/2 0/3 0/3 0/3 0/1 0/2 0/3 0/5 0/8 +012345678 36 xxxxxxxxxxxxx xxxxxxxxxxxxxxx 0 0 t 0 + g 3 n + + * 0 0 18 n.b. 0/2 0/4 1/2 0/4 2/2 3/3 2/3 3/3 1/1 2/2 4/3 0/5 0/8 +012345678 85 xxxxxxxxxxxxx xxxxxxxxxxxxxxx u v z 0 g x n + v g v v G 35 1.7 2/2 4/4 1/2 0/4 2/2 3/3 2/3 3/3 1/1 2/2 3/3 5/5 7/8 +012345678 00 xxxxxxxxxxxxx xxxxxxxxxxxxxxx + h . 0 p v n 0 + u . 0 A 17 n.b. 2/2 4/4 0/2 0/4 2/2 3/3 2/3 0/3 1/1 2/2 0/3 0/5 1/8 +012345678 41 xxxxxxxxxxxxx xxxxxxxxxxxxxxx v S z v g e G b g g g v 0 28 2.7 2/2 3/4 1/2 4/4 2/2 2/3 2/3 1/3 1/1 2/2 3/3 5/5 0/8 +# ----------------------------------------------------------------------- 1a b c d 2a b c d 3a b c d 4 +## Aufgabe 1 1 1 1 2 2 2 2 3 3 3 3 4 +## Teilaufgabe a b c d a b c d a b c d x +## Punkte 2 4 2 4 2 3 3 3 1 2 3 5 8 ======== +@# +@# # +@# # # # +@# # # # ## ## # # # ## # ## +@# 0----+----1----+----2----+----3----+----4--- +@# . 4+ - 3 + - 2 + - 1 + +@# +@# \score{0}{1}\score{7}{1}\score{14}{1}\score{17}{1}\score{18}{1}\score{21}{1}\score{22}{2}\score{28}{2}\score{30}{1}\score{33}{1}\score{35}{3}\score{36}{1}\score{38}{1}\score{42}{1}\score{43}{1} +@# \mark{0.7}{42}\mark{1.0}{40}\mark{1.3}{38}\mark{1.7}{35}\mark{2.0}{33}\mark{2.3}{30}\mark{2.7}{28}\mark{3.0}{25}\mark{3.3}{23}\mark{3.7}{21}\mark{4.0}{20}\mark{n.b.}{0} +@# diff --git a/20240620/bewert.pas b/20240620/bewert.pas new file mode 100644 index 0000000..b6a7855 --- /dev/null +++ b/20240620/bewert.pas @@ -0,0 +1,396 @@ +{ Bewert - Rate an Examination + + Copyright 2012, 2018, 2019 Peter Gerwinski <http://www.peter.gerwinski.de> + + This program is free software: you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +} + +program Bewert; + +uses + GPC, GPCUtil; + +const + MaxMarks = 100; + MaxScores = 1000; + +type + PDecl = ^TDecl; + PIDLine = ^TIDLine; + + TDecl = record + Symbol: Char; + Factor, Increment: Real; + Condition: PString; + Next: PDecl + end; + + TIDLine = record + Line: PString; + Next: PIDLine + end; + + TMark = record + Score: Integer; + Mark: String[10] + end; + +var + Line: TString; + DeclPart: Boolean = true; + Decl: PDecl = nil; + ExitCode: Integer = 0; + ScoreLine: PString = nil; + IDLine: PIDLine = nil; + Marks: Integer = 0; + MarkTable: array[1..MaxMarks] of TMark; + ScoreTable: array[0..MaxScores] of Integer; + ScoreTableMax: Integer = 0; + MaxTotalScore: Real = 0.0; + +procedure Error (var Line: String; const Msg: String); +begin + ExitCode := 1; + Line := Line + ' <-- ' + Msg +end; + +procedure SkipSpace (const Line: String; var p: Integer); +begin + while (p <= Length (Line)) and IsSpace (Line[p]) do + Inc (p) +end; + +procedure AdvanceTo (const Line: String; var p: Integer; Expected: CharSet); +begin + while (p <= Length (Line)) and not (Line[p] in Expected) do + Inc (p) +end; + +procedure ReadNumber (var Line: String; var p: Integer; var x: Real); +var + p0: Integer; +begin + p0 := p; + while (p <= Length (Line)) and (Line[p] in ['0'..'9', '.']) do + Inc (p); + if p > p0 then + ReadStr (Line[p0 .. p - 1], x) + else + Error (Line, 'malformed declaration: number expected') +end; + +procedure AdvanceAndReadNumber (var Line: String; var p: Integer; var x: Real); +begin + Inc (p); + SkipSpace (Line, p); + ReadNumber (Line, p, x) +end; + +procedure HandleRating (var Line: String); +var + p, q, i: Integer; + ID: PIDLine; + TotalScore, MaxScore: Real; + ScoreStr: TString; + + procedure ProcessMarkLine (Line: String); + var + p, Score: Integer; + Mark: TString; + begin + Delete (Line, 1, 2); + p := Pos ('=', Line); + Str2Int (Copy (Line, 1, p - 1), Score); + Mark := Copy (Line, p + 1); + TrimBoth (Mark); + Inc (Marks); + MarkTable[Marks].Score := Score; + MarkTable[Marks].Mark := Mark + end; + + function Score (var Line: String; p: Integer; MaxScore: Real): Real; + var + D: PDecl; + + function Matches (D: PDecl; Symbol: Char; p: Integer): Boolean; + var + Condition: TString; + ID: PIDLine; + begin + if D^.Symbol = Symbol then + if D^.Condition = nil then + Matches := true + else + begin + Condition := ''; + ID := IDLine; + while ID <> nil do + begin + if (ID^.Line <> nil) and (p <= Length (ID^.Line^)) and (ID^.Line^[p] <> ' ') then + if Condition = '' then + Condition := ID^.Line^[p] + else + Condition := ID^.Line^[p] + '.' + Condition; + ID := ID^.Next + end; + Matches := Condition = D^.Condition^ + end + else + Matches := false + end; + + begin + D := Decl; + while (D <> nil) and not Matches (D, Line[p], p) do + D := D^.Next; + if D = nil then + begin + Error (Line, 'unknown symbol "' + Line[p] + '"'); + Score := MaxScore + end + else + Score := Round (D^.Factor * MaxScore + D^.Increment) + end; + +begin + p := 1; + SkipSpace (Line, p); + if p <= Length (Line) then + if (Line[p] in ['@', '=', '>']) and (p < Length (Line)) and (Line[p + 1] = Line[p]) then + if (Line[p] = '=') then + ScoreLine := NewString (Line) + else if (Line[p] = '>') then + ProcessMarkLine (Line) + else + begin + New (ID); + ID^.Line := NewString (Line); + ID^.Next := IDLine; + IDLine := ID + end + else if Line[p] <> '#' then + if ScoreLine = nil then + begin + Error (Line, 'missing scores'); + ScoreLine := NewString ('') + end + else + begin + Delete (Line, Length (ScoreLine^) + 1); + while Length (Line) < Length (ScoreLine^) + 1 do + Line := Line + ' '; + p := 1; + AdvanceTo (ScoreLine^, p, ['0'..'9', '.']); + TotalScore := 0.0; + while (p <= Length (ScoreLine^)) and (ScoreLine^[p] <> '=') do + begin + q := p; + ReadNumber (ScoreLine^, p, MaxScore); + SkipSpace (ScoreLine^, p); + SkipSpace (Line, q); + + WriteStr (ScoreStr, Score (Line, q, MaxScore) : 0 : 0); + Line := Line + ' ' + ScoreStr; + WriteStr (ScoreStr, MaxScore : 0 : 0); + Line := Line + '/' + ScoreStr; + + TotalScore := TotalScore + Score (Line, q, MaxScore) + end; + Inc (ScoreTable[Round (TotalScore)]); + if ScoreTableMax < ScoreTable[Round (TotalScore)] then + ScoreTableMax := ScoreTable[Round (TotalScore)]; + if TotalScore > MaxTotalScore then + MaxTotalScore := TotalScore; + if (p <= Length (ScoreLine^)) and (ScoreLine^[p] = '=') then + begin + q := p + 1; + while (q <= Length (ScoreLine^)) and (ScoreLine^[q] = '=') do + Inc (q); + Dec (q); + WriteStr (ScoreStr, TotalScore : 3 : 0); + + i := 1; + while i <= Marks do + if TotalScore >= MarkTable[i].Score then + begin + WriteStr (ScoreStr, ScoreStr, ' ', MarkTable[i].Mark : -(q - p + 1 - 3)); + i := Marks + 1 + end + else + Inc (i); + + for i := p to q do + Line[i] := ScoreStr[i - p + 1] + end + end +end; + +procedure HandleDecl (var Line: String); +var + p, q, q0: Integer; + D: PDecl; +begin + p := 1; + SkipSpace (Line, p); + if p <= Length (Line) then + if (Line[p] in ['@', '=', '>']) and (p < Length (Line)) and (Line[p + 1] = Line[p]) then + begin + DeclPart := false; + HandleRating (Line) + end + else + begin + New (D); + D^.Symbol := Line[p]; + Inc (p); + SkipSpace (Line, p); + if (p <= Length (Line)) and (Line[p] = '@') then + begin + q := p + 1; + SkipSpace (Line, q); + q0 := q; + AdvanceTo (Line, q, ['='] + SpaceCharacters); + D^.Condition := NewString (Line[q0 .. q - 1]); + p := q; + AdvanceTo (Line, p, ['=']) + end + else + D^.Condition := nil; + if (p <= Length (Line)) and (Line[p] = '=') then + begin + Inc (p); + SkipSpace (Line, p); + if (p <= Length (Line)) and (Line[p] = 'P') then + begin + Inc (p); + SkipSpace (Line, p); + if (p <= Length (Line)) and (Line[p] = '+') then + begin + AdvanceAndReadNumber (Line, p, D^.Increment); + D^.Factor := 1.0 + end + else if (p <= Length (Line)) and (Line[p] = '-') then + begin + AdvanceAndReadNumber (Line, p, D^.Increment); + D^.Increment := -D^.Increment; + D^.Factor := 1.0 + end + else if (p <= Length (Line)) and (Line[p] = '*') then + begin + AdvanceAndReadNumber (Line, p, D^.Factor); + SkipSpace (Line, p); + if (p <= Length (Line)) and (Line[p] = '+') then + AdvanceAndReadNumber (Line, p, D^.Increment) + else + D^.Increment := 0.0 + end + else if (p > Length (Line)) or (Line[p] = '#') then + begin + D^.Factor := 1.0; + D^.Increment := 0.0 + end + else + Error (Line, 'malformed declaration: "+", "-", or "*" expected') + end + else + begin + ReadNumber (Line, p, D^.Increment); + D^.Factor := 0.0 + end + end + else + begin + Error (Line, 'malformed declaration: "@" or "=" expected'); + D^.Factor := 0.0; + D^.Increment := 0.0 + end; + D^.Next := Decl; + Decl := D + end +end; + +procedure ShowHistogram; +var + Number, Score, i: Integer; + Symbol: Char; +begin + WriteLn ('@#'); + for Number := ScoreTableMax downto 1 do + begin + Write ('@# '); + for Score := 0 to Round (MaxTotalScore) do + if ScoreTable[Score] >= Number then + Write ('#') + else + Write (' '); + WriteLn + end; + Write ('@# '); + for Score := 0 to Round (MaxTotalScore) do + if Score mod 10 = 0 then + Write ((Score div 10) mod 10) + else if Score mod 5 = 0 then + Write ('+') + else + Write ('-'); + WriteLn; + Write ('@# '); + for Score := 0 to Round (MaxTotalScore) do + begin + Symbol := ' '; + for i := 1 to Marks do + if MarkTable[i].Score = Score then + begin + Symbol := MarkTable[i].Mark[Length(MarkTable[i].Mark)]; + if Symbol = '0' then + Symbol := MarkTable[i].Mark[1] + else if Symbol = '3' then + Symbol := '-' + else if Symbol = '7' then + Symbol := '+' + end; + Write (Symbol) + end; + WriteLn; + WriteLn ('@#'); + Write ('@# '); + for Score := 0 to Round (MaxTotalScore) do + if ScoreTable[Score] > 0 then + Write ('\score{', Score, '}{', ScoreTable[Score], '}'); + WriteLn; + Write ('@# '); + for i := 1 to Marks do + Write ('\mark{', MarkTable[i].Mark, '}{', MarkTable[i].Score, '}'); + WriteLn; + WriteLn ('@#') +end; + +begin + while not EOF do + begin + ReadLn (Line); + if (Length (Line) >= 2) and (Copy (Line, 1, 2) = '@#') then + { delete this line } + else + begin + if DeclPart then + HandleDecl (Line) + else + HandleRating (Line); + WriteLn (Line) + end + end; + ShowHistogram; + Halt (ExitCode) +end. diff --git a/20240620/const-01.c b/20240620/const-01.c new file mode 100644 index 0000000..983ac6b --- /dev/null +++ b/20240620/const-01.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +int main (void) +{ + const int n = 5; + int prime [n] = { 2, 3, 5, 7, 11 }; + for (int i = 0; i < n; i++) + printf ("%d ", prime[i]); + printf ("\n"); + return 0; +} diff --git a/20240620/const-01.cpp b/20240620/const-01.cpp new file mode 100644 index 0000000..983ac6b --- /dev/null +++ b/20240620/const-01.cpp @@ -0,0 +1,11 @@ +#include <stdio.h> + +int main (void) +{ + const int n = 5; + int prime [n] = { 2, 3, 5, 7, 11 }; + for (int i = 0; i < n; i++) + printf ("%d ", prime[i]); + printf ("\n"); + return 0; +} diff --git a/20240620/const-02.c b/20240620/const-02.c new file mode 100644 index 0000000..9067158 --- /dev/null +++ b/20240620/const-02.c @@ -0,0 +1,19 @@ +#include <stdio.h> + +int fak (int n) +{ + int result = 1; + for (int i = 2; i <= n; i++) + result *= i; + return result; +} + +int main (void) +{ + const int n = fak (3); + int prime [n] = { 2, 3, 5, 7, 11, 13 }; + for (int i = 0; i < n; i++) + printf ("%d ", prime[i]); + printf ("\n"); + return 0; +} diff --git a/20240620/const-03.c b/20240620/const-03.c new file mode 100644 index 0000000..69e2064 --- /dev/null +++ b/20240620/const-03.c @@ -0,0 +1,20 @@ +#include <stdio.h> + +int fak (int n) +{ + int result = 1; + for (int i = 2; i <= n; i++) + result *= i; + return result; +} + +const int n = fak (3); +int prime [n] = { 2, 3, 5, 7, 11, 13 }; + +int main (void) +{ + for (int i = 0; i < n; i++) + printf ("%d ", prime[i]); + printf ("\n"); + return 0; +} diff --git a/20240620/const-04.c b/20240620/const-04.c new file mode 100644 index 0000000..42ac41a --- /dev/null +++ b/20240620/const-04.c @@ -0,0 +1,20 @@ +#include <stdio.h> + +constexpr int fak (int n) +{ + int result = 1; + for (int i = 2; i <= n; i++) + result *= i; + return result; +} + +const int n = fak (3); +int prime [n] = { 2, 3, 5, 7, 11, 13 }; + +int main (void) +{ + for (int i = 0; i < n; i++) + printf ("%d ", prime[i]); + printf ("\n"); + return 0; +} diff --git a/20240620/functions-01.cpp b/20240620/functions-01.cpp new file mode 100644 index 0000000..a1849bb --- /dev/null +++ b/20240620/functions-01.cpp @@ -0,0 +1,18 @@ +#include <stdio.h> + +void print (char *s) +{ + printf ("%s\n", s); +} + +void print (int i) +{ + printf ("%d\n", i); +} + +int main () +{ + print ("Hello, world!"); + print (42); + return 0; +} diff --git a/20240620/functions-02.cpp b/20240620/functions-02.cpp new file mode 100644 index 0000000..2900d5b --- /dev/null +++ b/20240620/functions-02.cpp @@ -0,0 +1,18 @@ +#include <stdio.h> + +void print (const char *s) +{ + printf ("%s\n", s); +} + +void print (int i) +{ + printf ("%d\n", i); +} + +int main () +{ + print ("Hello, world!"); + print (42); + return 0; +} diff --git a/20240620/functions-03.cpp b/20240620/functions-03.cpp new file mode 100644 index 0000000..9368c8d --- /dev/null +++ b/20240620/functions-03.cpp @@ -0,0 +1,18 @@ +#include <stdio.h> + +void print (const char *s = "Hello, world!") +{ + printf ("%s\n", s); +} + +void print (int i = 42) +{ + printf ("%d\n", i); +} + +int main () +{ + print ("Hello, world!"); + print (42); + return 0; +} diff --git a/20240620/functions-04.cpp b/20240620/functions-04.cpp new file mode 100644 index 0000000..5a6f8a2 --- /dev/null +++ b/20240620/functions-04.cpp @@ -0,0 +1,19 @@ +#include <stdio.h> + +void print (const char *s = "Hello, world!") +{ + printf ("%s\n", s); +} + +void print (int i = 42) +{ + printf ("%d\n", i); +} + +int main () +{ + print ("Hello, world!"); + print (42); + print (); + return 0; +} diff --git a/20240620/functions-05.cpp b/20240620/functions-05.cpp new file mode 100644 index 0000000..88409e3 --- /dev/null +++ b/20240620/functions-05.cpp @@ -0,0 +1,19 @@ +#include <stdio.h> + +void print (const char *s = "Hello, world!") +{ + printf ("%s\n", s); +} + +void print (int i) +{ + printf ("%d\n", i); +} + +int main () +{ + print ("Hello, world!"); + print (42); + print (); + return 0; +} diff --git a/20240620/functions-05.s b/20240620/functions-05.s new file mode 100644 index 0000000..5aa696c --- /dev/null +++ b/20240620/functions-05.s @@ -0,0 +1,65 @@ + .file "functions-05.cpp" + .text + .globl _Z5printPKc + .type _Z5printPKc, @function +_Z5printPKc: +.LFB12: + .cfi_startproc + subq $8, %rsp + .cfi_def_cfa_offset 16 + call puts@PLT + addq $8, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE12: + .size _Z5printPKc, .-_Z5printPKc + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "%d\n" + .text + .globl _Z5printi ; #include <stdio.h> + .type _Z5printi, @function ; +_Z5printi: ; void print (const char *s = "Hello, world!") +.LFB13: ; { + .cfi_startproc ; printf ("%s\n", s); + subq $8, %rsp ; } + .cfi_def_cfa_offset 16 ; + movl %edi, %esi ; void print (int i) + leaq .LC0(%rip), %rdi ; { + movl $0, %eax ; printf ("%d\n", i); + call printf@PLT ; } + addq $8, %rsp ; + .cfi_def_cfa_offset 8 ; int main () + ret ; { + .cfi_endproc ; print ("Hello, world!"); +.LFE13: ; print (42); + .size _Z5printi, .-_Z5printi ; print (); + .section .rodata.str1.1 ; return 0; +.LC1: ; } + .string "Hello, world!" + .text + .globl main + .type main, @function +main: +.LFB14: + .cfi_startproc + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + leaq .LC1(%rip), %rbx + movq %rbx, %rdi + call puts@PLT + movl $42, %edi + call _Z5printi + movq %rbx, %rdi + call puts@PLT + movl $0, %eax + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE14: + .size main, .-main + .ident "GCC: (Debian 12.2.0-14) 12.2.0" + .section .note.GNU-stack,"",@progbits diff --git a/20240620/functions-06.cpp b/20240620/functions-06.cpp new file mode 100644 index 0000000..699cfad --- /dev/null +++ b/20240620/functions-06.cpp @@ -0,0 +1,9 @@ +#include "printlib-01.h" + +int main () +{ + print ("Hello, world!"); + print (42); + print (); + return 0; +} diff --git a/20240620/functions-07.cpp b/20240620/functions-07.cpp new file mode 100644 index 0000000..c4ded5a --- /dev/null +++ b/20240620/functions-07.cpp @@ -0,0 +1,9 @@ +#include "printlib-05.h" + +int main () +{ + print_string ("Hello, world!"); + print_int (42); + print_string (); + return 0; +} diff --git a/20240620/functions-07.s b/20240620/functions-07.s new file mode 100644 index 0000000..b07642e --- /dev/null +++ b/20240620/functions-07.s @@ -0,0 +1,30 @@ + .file "functions-07.cpp" + .text + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "Hello, world!" + .text + .globl main + .type main, @function +main: +.LFB0: + .cfi_startproc + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + leaq .LC0(%rip), %rbx + movq %rbx, %rdi + call _Z12print_stringPKc@PLT + movl $42, %edi + call _Z9print_inti@PLT + movq %rbx, %rdi + call _Z12print_stringPKc@PLT + movl $0, %eax + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE0: + .size main, .-main + .ident "GCC: (Debian 12.2.0-14) 12.2.0" + .section .note.GNU-stack,"",@progbits diff --git a/20240620/functions-08.cpp b/20240620/functions-08.cpp new file mode 100644 index 0000000..a0c4658 --- /dev/null +++ b/20240620/functions-08.cpp @@ -0,0 +1,9 @@ +#include "printlib-06.h" + +int main () +{ + print_string ("Hello, world!"); + print_int (42); + print_string (); + return 0; +} diff --git a/20240620/functions-08.s b/20240620/functions-08.s new file mode 100644 index 0000000..3cd0706 --- /dev/null +++ b/20240620/functions-08.s @@ -0,0 +1,30 @@ + .file "functions-08.cpp" + .text + .section .rodata.str1.1,"aMS",@progbits,1 +.LC0: + .string "Hello, world!" + .text + .globl main + .type main, @function +main: +.LFB0: + .cfi_startproc + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + leaq .LC0(%rip), %rbx + movq %rbx, %rdi + call print_string@PLT + movl $42, %edi + call print_int@PLT + movq %rbx, %rdi + call print_string@PLT + movl $0, %eax + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE0: + .size main, .-main + .ident "GCC: (Debian 12.2.0-14) 12.2.0" + .section .note.GNU-stack,"",@progbits diff --git a/20240620/hello-01.cpp b/20240620/hello-01.cpp new file mode 100644 index 0000000..04f85e5 --- /dev/null +++ b/20240620/hello-01.cpp @@ -0,0 +1,7 @@ +#include <iostream> + +int main () +{ + std::cout << "Hello, world!" << std::endl; + return 0; +} diff --git a/20240620/hello-02.cpp b/20240620/hello-02.cpp new file mode 100644 index 0000000..4ff9a48 --- /dev/null +++ b/20240620/hello-02.cpp @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main () +{ + printf ("The answer is %d.\n", 21 << 1); + return 0; +} diff --git a/20240620/hello-03.cpp b/20240620/hello-03.cpp new file mode 100644 index 0000000..cbef37b --- /dev/null +++ b/20240620/hello-03.cpp @@ -0,0 +1,7 @@ +#include <iostream> + +int main () +{ + std::cout << "The answer is " << 21 << 1 << "." << std::endl; + return 0; +} diff --git a/20240620/hello-04.cpp b/20240620/hello-04.cpp new file mode 100644 index 0000000..5bc24fb --- /dev/null +++ b/20240620/hello-04.cpp @@ -0,0 +1,7 @@ +#include <iostream> + +int main () +{ + std::cout << "The answer is " << (21 << 1) << "." << std::endl; + return 0; +} diff --git a/20240620/mem-01.c b/20240620/mem-01.c new file mode 100644 index 0000000..7134feb --- /dev/null +++ b/20240620/mem-01.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <stdlib.h> + +int main (void) +{ + const int n = 5; + int *prime = malloc (n); // FALSCH!!! + prime[0] = 2; + prime[1] = 3; + prime[2] = 5; + prime[3] = 7; + prime[4] = 11; + for (int i = 0; i < n; i++) + printf ("%d ", prime[i]); + printf ("\n"); + return 0; +} diff --git a/20240620/mem-02.c b/20240620/mem-02.c new file mode 100644 index 0000000..829e7fb --- /dev/null +++ b/20240620/mem-02.c @@ -0,0 +1,17 @@ +#include <stdio.h> +#include <stdlib.h> + +int main (void) +{ + const int n = 5; + int *prime = malloc (n * sizeof (int)); + prime[0] = 2; + prime[1] = 3; + prime[2] = 5; + prime[3] = 7; + prime[4] = 11; + for (int i = 0; i < n; i++) + printf ("%d ", prime[i]); + printf ("\n"); + return 0; +} diff --git a/20240620/mem-03.c b/20240620/mem-03.c new file mode 100644 index 0000000..171b1d8 --- /dev/null +++ b/20240620/mem-03.c @@ -0,0 +1,10 @@ +#include <stdio.h> + +int main (void) +{ + int *two = new int; + *two = 2; + printf ("2 = %d\n", *two); + delete two; + return 0; +} diff --git a/20240620/operators-01.cpp b/20240620/operators-01.cpp new file mode 100644 index 0000000..b95183a --- /dev/null +++ b/20240620/operators-01.cpp @@ -0,0 +1,21 @@ +#include <iostream> + +struct vector +{ + double x, y, z; +}; + +vector operator + (vector u, vector v) +{ + vector w = { u.x + v.x, u.y + v.y, u.z + v.z }; + return w; +} + +int main () +{ + vector a = { 1, 0, 0 }; + vector b = { 0, 1, 0 }; + vector c = a + b; + printf ("c = (%lf, %lf, %lf)\n", c.x, c.y, c.z); + return 0; +} diff --git a/20240620/operators-01.s b/20240620/operators-01.s new file mode 100644 index 0000000..b8bed9e --- /dev/null +++ b/20240620/operators-01.s @@ -0,0 +1,78 @@ + .file "operators-01.cpp" + .text + .globl _Zpl6vectorS_ + .type _Zpl6vectorS_, @function +_Zpl6vectorS_: +.LFB1782: + .cfi_startproc + movq %rdi, %rax + movsd 8(%rsp), %xmm0 + addsd 32(%rsp), %xmm0 + movsd %xmm0, (%rdi) + movsd 16(%rsp), %xmm0 + addsd 40(%rsp), %xmm0 + movsd %xmm0, 8(%rdi) + movsd 24(%rsp), %xmm0 + addsd 48(%rsp), %xmm0 + movsd %xmm0, 16(%rdi) + ret + .cfi_endproc +.LFE1782: + .size _Zpl6vectorS_, .-_Zpl6vectorS_ + .section .rodata.str1.1,"aMS",@progbits,1 +.LC1: + .string "c = (%lf, %lf, %lf)\n" + .text + .globl main + .type main, @function +main: +.LFB1783: + .cfi_startproc + subq $8, %rsp + .cfi_def_cfa_offset 16 ; int main () + movsd .LC0(%rip), %xmm0 ; { + pxor %xmm2, %xmm2 ; vector a = { 1, 0, 0 }; + movapd %xmm0, %xmm1 ; vector b = { 0, 1, 0 }; + leaq .LC1(%rip), %rdi ; vector c = a + b; + movl $3, %eax ; printf ("c = (%lf, %lf, %lf)\n", c.x, c.y, c.z); + call printf@PLT ; return 0; + movl $0, %eax ; } + addq $8, %rsp + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE1783: + .size main, .-main + .type _GLOBAL__sub_I__Zpl6vectorS_, @function +_GLOBAL__sub_I__Zpl6vectorS_: +.LFB2308: + .cfi_startproc + pushq %rbx + .cfi_def_cfa_offset 16 + .cfi_offset 3, -16 + leaq _ZStL8__ioinit(%rip), %rbx + movq %rbx, %rdi + call _ZNSt8ios_base4InitC1Ev@PLT + leaq __dso_handle(%rip), %rdx + movq %rbx, %rsi + movq _ZNSt8ios_base4InitD1Ev@GOTPCREL(%rip), %rdi + call __cxa_atexit@PLT + popq %rbx + .cfi_def_cfa_offset 8 + ret + .cfi_endproc +.LFE2308: + .size _GLOBAL__sub_I__Zpl6vectorS_, .-_GLOBAL__sub_I__Zpl6vectorS_ + .section .init_array,"aw" + .align 8 + .quad _GLOBAL__sub_I__Zpl6vectorS_ + .local _ZStL8__ioinit + .comm _ZStL8__ioinit,1,1 + .section .rodata.cst8,"aM",@progbits,8 + .align 8 +.LC0: + .long 0 + .long 1072693248 + .hidden __dso_handle + .ident "GCC: (Debian 12.2.0-14) 12.2.0" + .section .note.GNU-stack,"",@progbits diff --git a/20240620/operators-02.cpp b/20240620/operators-02.cpp new file mode 100644 index 0000000..8d54ab7 --- /dev/null +++ b/20240620/operators-02.cpp @@ -0,0 +1,20 @@ +#include <iostream> + +struct vector +{ + int x, y, z; +}; + +vector operator ++ (vector v) +{ + vector w = { v.x++, v.y++, v.z++ }; + return w; +} + +int main () +{ + vector a = { 1, 0, 0 }; + vector c = a++; + printf ("c = (%d, %d, %d)\n", c.x, c.y, c.z); + return 0; +} diff --git a/20240620/operators-03.cpp b/20240620/operators-03.cpp new file mode 100644 index 0000000..5b70998 --- /dev/null +++ b/20240620/operators-03.cpp @@ -0,0 +1,20 @@ +#include <iostream> + +struct vector +{ + int x, y, z; +}; + +vector operator ++ (vector v) +{ + vector w = { ++v.x, ++v.y, ++v.z }; + return w; +} + +int main () +{ + vector a = { 1, 0, 0 }; + vector c = ++a; + printf ("c = (%d, %d, %d)\n", c.x, c.y, c.z); + return 0; +} diff --git a/20240620/operators-04.cpp b/20240620/operators-04.cpp new file mode 100644 index 0000000..9bedc5b --- /dev/null +++ b/20240620/operators-04.cpp @@ -0,0 +1,20 @@ +#include <iostream> + +struct vector +{ + int x, y, z; +}; + +vector operator ++ (vector v, int) +{ + vector w = { v.x++, v.y++, v.z++ }; + return w; +} + +int main () +{ + vector a = { 1, 0, 0 }; + vector c = a++; + printf ("c = (%d, %d, %d)\n", c.x, c.y, c.z); + return 0; +} diff --git a/20240620/printlib-01.c b/20240620/printlib-01.c new file mode 100644 index 0000000..078da53 --- /dev/null +++ b/20240620/printlib-01.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +void _Z5printPKc (const char *s = "Hello, world!") +{ + printf ("%s\n", s); +} + +void _Z5printi (int i) +{ + printf ("%d\n", i); +} diff --git a/20240620/printlib-01.h b/20240620/printlib-01.h new file mode 100644 index 0000000..5d61c18 --- /dev/null +++ b/20240620/printlib-01.h @@ -0,0 +1,2 @@ +extern void print (const char *s = "Hello, world!"); +extern void print (int i); diff --git a/20240620/printlib-02.c b/20240620/printlib-02.c new file mode 100644 index 0000000..3bdb1ff --- /dev/null +++ b/20240620/printlib-02.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +void _Z5printPKc (const char *s) +{ + printf ("%s\n", s); +} + +void _Z5printi (int i) +{ + printf ("%d\n", i); +} diff --git a/20240620/printlib-03.cpp b/20240620/printlib-03.cpp new file mode 100644 index 0000000..40a9928 --- /dev/null +++ b/20240620/printlib-03.cpp @@ -0,0 +1,11 @@ +#include <stdio.h> + +void print (const char *s) +{ + printf ("%s\n", s); +} + +void print (int i) +{ + printf ("%d\n", i); +} diff --git a/20240620/printlib-04.cpp b/20240620/printlib-04.cpp new file mode 100644 index 0000000..21ddd0a --- /dev/null +++ b/20240620/printlib-04.cpp @@ -0,0 +1,12 @@ +#include <stdio.h> +#include "printlib-01.h" + +void print (const char *s) +{ + printf ("%s\n", s); +} + +void print (int i) +{ + printf ("%d\n", i); +} diff --git a/20240620/printlib-05.c b/20240620/printlib-05.c new file mode 100644 index 0000000..906911e --- /dev/null +++ b/20240620/printlib-05.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +void print_string (const char *s) +{ + printf ("%s\n", s); +} + +void print_int (int i) +{ + printf ("%d\n", i); +} diff --git a/20240620/printlib-05.h b/20240620/printlib-05.h new file mode 100644 index 0000000..1f21842 --- /dev/null +++ b/20240620/printlib-05.h @@ -0,0 +1,2 @@ +extern void print_string (const char *s = "Hello, world!"); +extern void print_int (int i); diff --git a/20240620/printlib-06.h b/20240620/printlib-06.h new file mode 100644 index 0000000..00dd7d8 --- /dev/null +++ b/20240620/printlib-06.h @@ -0,0 +1,5 @@ +extern "C" +{ + extern void print_string (const char *s = "Hello, world!"); + extern void print_int (int i); +} diff --git a/20240620/references-01.c b/20240620/references-01.c new file mode 100644 index 0000000..0d5039a --- /dev/null +++ b/20240620/references-01.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void calc_answer (int *answer) +{ + *answer = 42; +} + +int main (void) +{ + int a; + calc_answer (&a); + printf ("The answer is %d.\n", a); + return 0; +} diff --git a/20240620/references-02.c b/20240620/references-02.c new file mode 100644 index 0000000..f4bb6e7 --- /dev/null +++ b/20240620/references-02.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void calc_answer (int &answer) +{ + answer = 42; +} + +int main (void) +{ + int a; + calc_answer (a); + printf ("The answer is %d.\n", a); + return 0; +} diff --git a/20240620/void-01.c b/20240620/void-01.c new file mode 100644 index 0000000..b19d80e --- /dev/null +++ b/20240620/void-01.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main (void) +{ + printf ("Hello, world!\n"); + return 0; +} diff --git a/20240620/void-02.c b/20240620/void-02.c new file mode 100644 index 0000000..845c95a --- /dev/null +++ b/20240620/void-02.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main () +{ + printf ("Hello, world!\n"); + return 0; +} diff --git a/20240620/void-03.c b/20240620/void-03.c new file mode 100644 index 0000000..e1adaf7 --- /dev/null +++ b/20240620/void-03.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +void hello () +{ + printf ("Hello, world!\n"); +} + +int main () +{ + hello (); + return 0; +} diff --git a/20240620/void-04.c b/20240620/void-04.c new file mode 100644 index 0000000..83ab741 --- /dev/null +++ b/20240620/void-04.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +void hello () +{ + printf ("Hello, world!\n"); +} + +int main () +{ + hello ("world"); + return 0; +} diff --git a/20240620/void-05.c b/20240620/void-05.c new file mode 100644 index 0000000..02e0304 --- /dev/null +++ b/20240620/void-05.c @@ -0,0 +1,12 @@ +#include <stdio.h> + +void hello (void) +{ + printf ("Hello, world!\n"); +} + +int main (void) +{ + hello ("world"); + return 0; +} diff --git a/20240620/void-06.c b/20240620/void-06.c new file mode 100644 index 0000000..1dd005e --- /dev/null +++ b/20240620/void-06.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +void hello (world) + char *world; +{ + printf ("Hello, %s!\n", world); +} + +int main () +{ + hello ("world"); + return 0; +} diff --git a/20240620/void-07.c b/20240620/void-07.c new file mode 100644 index 0000000..3ffbd80 --- /dev/null +++ b/20240620/void-07.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +void hello (world) + char *world; +{ + printf ("Hello, %s!\n", world); +} + +int main () +{ + hello ("world", 42); + return 0; +} diff --git a/20240620/void-08.c b/20240620/void-08.c new file mode 100644 index 0000000..1e78ecb --- /dev/null +++ b/20240620/void-08.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void hello (answer, world) + int answer; + char *world; +{ + printf ("Hello, %s!\nThe answer is %d.\n", world, answer); +} + +int main () +{ + hello ("world", 42); + return 0; +} diff --git a/20240620/void-09.c b/20240620/void-09.c new file mode 100644 index 0000000..6ecefc3 --- /dev/null +++ b/20240620/void-09.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void hello (answer, world) + int answer; + char *world; +{ + printf ("Hello, %s!\nThe answer is %d.\n", world, answer); +} + +int main () +{ + hello (42, "world"); + return 0; +} diff --git a/20240620/void-10.c b/20240620/void-10.c new file mode 100644 index 0000000..699e57c --- /dev/null +++ b/20240620/void-10.c @@ -0,0 +1,14 @@ +#include <stdio.h> + +void hello (answer, world) + int answer; + char *world; +{ + printf ("Hello, %s!\nThe answer is %d.\n", world, answer); +} + +int main () +{ + hello (); + return 0; +} diff --git a/20240620/void-11.c b/20240620/void-11.c new file mode 100644 index 0000000..04e305b --- /dev/null +++ b/20240620/void-11.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +typedef struct +{ + int content; + node *next; +} node; + +int main () +{ + node *root = NULL; + return 0; +} diff --git a/20240620/void-12.c b/20240620/void-12.c new file mode 100644 index 0000000..45eb3d7 --- /dev/null +++ b/20240620/void-12.c @@ -0,0 +1,13 @@ +#include <stdio.h> + +typedef struct node +{ + int content; + struct node *next; +} node; + +int main () +{ + node *root = NULL; + return 0; +} -- GitLab