Differences

This shows you the differences between two versions of the page.

wiki:study:prakt:ti [2005/06/13 22:33] (current)
Line 1: Line 1:
 +====== Technische Informatik ======
 +===== Aufgabe 1 =====
 +<code pascal>
 +program zeichenketten;
 +uses zeichenk;
 +var
 + woerter: array [1..5] of string [15];
 + nichttrennzeichen: integer;
 + pos: integer;
 + i: integer;
 +begin
 + Pos := 1;
 + nichttrennzeichen := 0;
 + for i := 1 to 5 do begin
 +  while zeichenkette[Pos] = trennzeichen do begin
 +  Inc(Pos);
 +  end;
 +  woerter[i] := '';
 +  while zeichenkette[Pos] <> trennzeichen do begin
 +  woerter[i] := Woerter[i] + Zeichenkette[Pos];
 +  Inc(Pos);
 +  Inc(Nichttrennzeichen);
 +  end;
 + end;
 +end.
 +</code>
 +===== Aufgabe 2 =====
 +<code pascal>
 +program Felder;
 +type figur = (
 +  keine_figur, s_koenig, w_koenig, s_dame, w_dame, s_laeufer,
 +  w_laeufer, s_springer, w_springer, s_turm, w_turm, s_bauer,
 +  w_bauer);
 + brett = array ['a'..'h', 1..8] of figur;
 +var
 +  schach: brett;
 +  buchst: char;
 +  zahl: integer;
 +begin
 + { 1. Anweisungsteil }
 + { Weiss }
 + schach['a',1] := w_turm;
 + schach['b',1] := w_springer;
 + schach['c',1] := w_laeufer;
 + schach['d',1] := w_dame;
 + schach['e',1] := w_koenig;
 + schach['f',1] := w_laeufer;
 + schach['g',1] := w_springer;
 + schach['h',1] := w_turm;
 + { Schwarz }
 + schach['a',8] := s_turm;
 + schach['b',8] := s_springer;
 + schach['c',8] := s_laeufer;
 + schach['d',8] := s_dame;
 + schach['e',8] := s_koenig;
 + schach['f',8] := s_laeufer;
 + schach['g',8] := s_springer;
 + schach['h',8] := s_turm;
 + { 2. Anweisungsteil }
 + for buchst := 'a' to 'h' do begin
 +  schach[buchst,2] := w_bauer;
 +  schach[buchst,7] := s_bauer;
 + end;
 + { 3. Anweisungsteil }
 + for buchst := 'a' to 'h' do begin
 +  for zahl := 3 to 6 do begin
 +  schach[buchst,zahl] := keine_figur;
 +  end;
 + end;
 +end.
 +</code>
 +
 +===== Aufgabe 3 =====
 +<code pascal>
 +program records;
 +type datum = record
 + tag, monat,jahr: integer;
 +end;
 +person = record
 + Name: string;
 + Vorname: string;
 + Geburtsdatum: datum;
 + verheiratet: boolean;
 +end;
 +var personen: array [1 .. 3] of person;
 +begin
 +  { Person 1 }
 +  personen[1].Name := 'Hans';
 +  personen[1].Vorname := 'Dieter';
 +  personen[1].Geburtsdatum.tag := 1;
 +  personen[1].Geburtsdatum.monat := 2;
 +  personen[1].Geburtsdatum.jahr := 1940;
 +  personen[1].verheiratet := TRUE;
 +  { Person 2 }
 +  with personen [2] do begin
 +    Name := 'Ernst';
 +    Vorname := 'Klaus';
 +    verheiratet := FALSE;
 +    with Geburtsdatum do begin
 +    tag := 10;
 +    monat := 9;
 +    jahr := 1950;
 +    end;
 +  end;
 +  { Person 3 }
 +  with personen[3] do begin
 +    Name := 'Schweiss';
 +    Vorname := 'Axel';
 +    verheiratet := TRUE;
 +  end;
 +  with personen[3].Geburtsdatum do begin
 +    tag := 20;
 +    monat := 12;
 +    jahr := 1960;
 +  end;
 +</code>
 +
 +===== Aufgabe 4 =====
 +<code pascal>
 +program gleitkommazahlen_double;
 +uses d_zahl;
 +var d: double;
 +begin
 + a := sin(a);
 + b := sqrt(b);
 + c := sqr(c);
 + d := a*b*c;
 +end.
 +program gleitkommazahlen_real;
 +uses r_zahl;
 +var d: real;
 +begin
 + a := sin(a);
 + b := sqrt(b);
 + c := sqr(c);
 + d := a*b*c;
 +end.
 +</code>
 +
 +===== Aufgabe 5 =====
 +<code pascal>
 +program case_und_if;
 +uses monat;
 +var tage: integer;
 +begin
 + case Mon of
 +  1, 3, 5, 7, 8, 10, 12:
 +  tage := 31;
 +
 +  4, 6, 9, 11:
 +  tage := 30;
 +
 +  2:
 +  case SJ of
 +    TRUE:
 +    tage := 29;
 +    FALSE:
 +    tage := 28;
 +  end;
 + end;
 + WriteLn (tage);
 +
 + if ((Mon = 1) or (Mon = 3) or (Mon = 5) or (Mon = 7) or
 +    (Mon = 8) or (Mon = 10) or (Mon = 12)) then begin
 +  tage := 31;
 + else if ((Mon = 4) or (Mon = 6) or (Mon = 9) or (Mon = 11)) then begin
 +  tage := 30;
 + else if (SJ) then begin
 +  tage := 29
 + else begin
 +  tage := 28;
 + end if;
 + WriteLn (tage);
 +end.
 +</code>
 +
 +===== Aufgabe 6 =====
 +<code pascal>
 +PROGRAM A6;
 +TYPE T_Memory = Array[0..255] of Byte;
 +VAR c : T_Memory;
 +  a, b, erg : Byte;
 +  bla : Byte;
 +BEGIN
 + for erg := 0 to 255 do begin
 +  c[erg] := 0;
 + end;
 + for a := 0 to 15 do begin
 +  for b := 0 to 15 do begin
 +  if (a = b) then begin
 +    erg := 0;
 +  else begin
 +    if (a < b) then begin
 +    erg := a
 +    end if;
 +  else begin
 +    erg := b;
 +    c[a+b*16] := erg;
 +  end;
 +  end;
 + end;
 +end.
 +</code>
 +
 +===== Aufgabe 7 =====
 +<code pascal>
 +program listen_;
 +uses liste;
 +var infos: array [1 .. max_Anzahl] of char;
 + Anzahl, i: integer;
 + Zeiger: Zeigertyp;
 +begin
 + for i := 1 to max_Anzahl do begin
 +  infos [i] := ' ';
 + end;
 + Anzahl := 0;
 + Zeiger := Listen;
 + while Zeiger <> nil do begin
 +  Inc (Anzahl);
 +  Infos [Anzahl] := Listen^.Info;
 +  Zeiger := Zeiger^.Zeiger;
 + end;
 + while Listen <> nil do begin
 +  Zeiger := Listen;
 +  Listen := Listen^.Zeiger;
 +  dispose (Zeiger);
 + end;
 +end.
 +</code>
 +
 +===== Aufgabe 8 =====
 +<code pascal>
 +program tabelle_logik;
 +type tabellenzeile = record
 + index: integer;
 + x3, x2, x1, x0: boolean;
 + y: boolean;
 + unbenutzt: byte;
 +end;
 +function Y (x3, x2, x1, x0: boolean): boolean;
 +begin
 + y := ( ((not x3) and (not x2) and x1 and (not x0)) or
 +        ((not x3) and x2 and x1 and (not x0)) or
 +        (x3 and (not x2) and x1 and (not x0)) or
 +        (x3 and x2) );
 +end;
 +var
 + tabelle: array [0 .. 15] of tabellenzeile;
 + x3, x2, x1, x0: boolean;
 + i: integer;
 +begin
 + i := 0;
 + for x3 := FALSE to TRUE do begin
 +  for x2 := FALSE to TRUE do begin
 +  for x1 := FALSE to TRUE do begin
 +    for x0 := FALSE to TRUE do begin
 +    tabelle[i].index := i;
 +    tabelle[i].x3 := x3;
 +    tabelle[i].x2 := x2;
 +    tabelle[i].x1 := x1;
 +    tabelle[i].x0 := x0;
 +    tabelle[i].y := Y(x3, x2, x1, x0);
 +    writeln;
 +    inc (i);
 +    end;
 +  end;
 +  end;
 + end;
 +end.
 +</code>
 
wiki/study/prakt/ti.txt · Last modified: 2005/06/13 22:33 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki