Lösung Blatt 5 AI 1 WS 99


Aufgabe 1:

a) Hex 25F6 == Dez 9718
b) Dez 10467 == Hex 28e3
c) Dez 10467 == Hex 28e3 ==  Bin 
0010 
1000
 1110
0011
2
8
e
3
          (Skript S. 42 unten)
 

Aufgabe 2:

(* Verwandeln einer Dezimalzahl in eine Octalzahl *)
(* x enthalte die zu verwandelnde Dezimalzahl *)

potenz=1;    (* Aktuelle 8er Potenz *)
if (x = 0) {    (* Sonderfall x=0 *)
     Ausgabe(0);
}

while (potenz <= x) {   (*  ermittle hoechste 8er-Potenz *)
     potenz = potenz*8;
}
potenz = potenz/8;   (*  eins zu weit gelaufen *)
(* oder auch kurz: potenz = 8 ^ int(log(x)/log(8)) *)

while (potenz >=1) {
     i = int(x/potenz);  (*  Division ohne Rest *)
     Ausgabe(i);   (*  Ziffer ausgeben *)
     x = x - potenz*i;  (*  Rest der Division *)
     potenz = potenz/8;  (*  nextniedriegere Potenz *)
}

Aufgabe 3:

a) grep "^94:" labor.dat | grep "\.1984:" | wc -l
b) cut -d: -f3 labor.dat | sort -n -r | head -1
c) grep ":[1-9][0-9]\.[0-9]$" labor.dat | wc -l