Autor Beitrag
Anja
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

WIN xp

BeitragVerfasst: Mo 26.05.03 09:36 
Ich brauche dringen eure hilfe! Wir sollen ein struktogramm und das programm entwerfen wie man eine Dualzahl in Hexa umwandelt. Also einen sogenannten umrechner. Kann mir bitte jemand helfen!

Gruß Anja
Luncustaf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 324

Win 2k
D7 Ent.
BeitragVerfasst: Mo 26.05.03 09:43 
hi,

schau dir in der hilfe mal die funktion -> IntToHex an


gr€€tz
Anja Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

WIN xp

BeitragVerfasst: Mo 26.05.03 09:50 
Titel: nährere erläutern
kannst du mir dasn mal näher aufschreiben
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mo 26.05.03 09:53 
Hi!

Was verstehst du unter einer Dualzahl? Einen beliebig langen String, der nur Nullen und Einsen enthält, oder einen vordefinierten Datentypen wie Cardinal, Integer, Byte etc.?

Cu,
Udontknow
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mo 26.05.03 10:47 
Hier mal Anjas Routinen für die Umwandlung:

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
function DezToBin(dezi:string):string;
var
  zahl,erg,rest :Integer;
  ergstr        :String;
  x: Integer;

  begin
    zahl:=StrToInt(dezi);
    ergstr:='';
    Repeat
      erg    := zahl DIV 2;
      rest   := zahl MOD 2;
      ergstr := IntToStr(rest)+ergstr;
      zahl   := erg;
    Until erg=0;
    Result := ergstr;
  end;

function BinToHexa(text:string):string;
  const
    symbole='123456789ABCDEF';

  var
    l:
    i:
    k:
    erg:
    kerg:

  begin
    While
      i:= '';
      

    Do

  end;


Also, was mir auffällt, ist, daß die Funktion DezToBin überlange Zahlen nicht verträgt (die Variable Zahl kann nicht beliebig große Werte annehmen). Daher meine Frage: Sind es beliebig lange Strings, die vorm Programm erwartet werden, oder ist die Länge begrenzt?

Cu,
Udontknow
Anja Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

WIN xp

BeitragVerfasst: Mo 26.05.03 11:26 
Titel: bin to hex
um deztobin geht es mir nicht mehr! Mir geht es nur ncoh um bintohex.Ich weiß nicht wie ich das mache ohne den befehl: Bintohex zu verwenden wir sollen nicht diesen befehl verwenden!

Gruß Anja
Anja Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

WIN xp

BeitragVerfasst: Mo 26.05.03 11:31 
Titel: entwurfstruktogramm
wie soll cih das strucktogramm malen!

Angefangen ist es schon cih weiß ncith wie es fertig aussehen muss!

Gruß Anja

kann es aber leider hir nicht einfügen
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mo 26.05.03 11:34 
na gut, wenn es dir darum nicht mehr geht...

BinToHex ist sehr einfach:
Je 4 Bit stellen ein Hexzeichen dar. Du musst also nur von hinten losmarschieren und dir die letzten 4 Dualziffern nehmen. Diese ergeben eine Hex-Zahl. Wenn du am Schluss weniger als 4 Ziffern hast, füllst du am Anfang einfach mit 0 auf.

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
10 1101 0001 0111
-----------

0111=4+2+1=7
0001=1
1101=8+4+1=13=D
10=0010=2

Ergebnis: 
2D17



PS: Du hast im Symbolstring die 0 vergessen, die ist auch eine Hex-Ziffer.

Cu,
Udontknow
Anja Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

WIN xp

BeitragVerfasst: Mo 26.05.03 11:39 
ich weiß ja wie das geht aber ich kann das nciht schreiben kannst du mir mal helfen?
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mo 26.05.03 12:35 
Bitte.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
function HexValue(BinValues:String):Integer;
var i:integer;
begin
  if Length(BinValues)>4 then
    raise Exception.Create('Überlauf');
  if (Length(BinValues)=0) or (StrToIntDef(BinValues,-1)=-1) then
    raise Exception.Create('Keine Zahl');
  Result:=0;
  for i:=1 to Length(BinValues) do
  begin
    Result:=Result*2;
    Result:=Result+StrToInt(BinValues[i]);
  end;
end;

function BinToHexa(text:string):string;
  const
    symbole='0123456789ABCDEF';
var BinValues:String;
var i:integer;
begin
  Result:='';
  //Start bei letzter Ziffer
  i:=length(text);
  repeat
    BinValues:='';
    repeat
      //Aktuelle binäre Ziffer nehmen
      BinValues:=Text[i]+BinValues;
      //nächste Ziffer (Position ändern)
      Dec(i);
    until (i=0) or (Length(BinValues)=4);
    //Entsprechendes Hex-Zeichen hinzufügen
    Result:=Symbole[HexValue(BinValues)+1]+Result;
  until i=0;
end;


Cu,
Udontknow


Moderiert von user profile icontommie-lie: Code- durch Delphi-Tags ersetzt
Anja Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

WIN xp

BeitragVerfasst: Mo 26.05.03 13:36 
es funktioniert net was muss cih noch tun, aber trotzdem erst mal danke! Wieso eght das nciht?
Anja Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

WIN xp

BeitragVerfasst: Mo 26.05.03 13:40 
ich danke allesn die mir geholfen haben.

Es funktioniert. Ihr habt mich glücklich gemacht. Nun muss ich nur noch das struktogramm zeichnen

Gruß Anja
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mo 26.05.03 13:41 
Moment, ich befrage meine Glaskugel... Ahhh! Die Glaskugel meint, du solltest genauer sein. :wink:

Was funktioniert denn nicht? Bekommst du eine Fehlermeldung? Wenn ja, welche, und wo steht dann der Compiler?

Edit: Hat sich erledigt? Na dann ist ja gut.

Cu,
Udontknow
Anja Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

WIN xp

BeitragVerfasst: Mo 26.05.03 13:45 
Titel: es
es funktioniert. Es geht ja!

nur weiß ich nciht was die befehle da bedeuten, kannste wird as ncoh näher erläutern damit ich das struktogramm alleine basten kann?

Gruß Anja
MaxiTB
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 679

Win2000, WinXp, Workbench ;-)
D7 Ent, VS2003 Arch.
BeitragVerfasst: Mo 26.05.03 14:05 
Titel: Hehe
Wieder mal eine Hausübung erledigt *lol*.

Warum hats damals nicht schon das Netz für meine Chemie-Aufgaben gegeben ? :lol:

_________________
Euer Mäxchen
Wer früher stirbt, ist länger tot.
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Mo 26.05.03 14:18 
@Anja:

MaxiTB spielt schon darauf an, weil ich die komplette Aufgabe im Grunde für dich gelöst habe, anstelle dich dazu zu bringen, sie selber zu lösen: Wenn du die Bedeutung eines Befehls nicht weisst, dann schau mal in die Delphi-Hilfe. Wenn die nichts bringt, suche mal im Forum. Und wenn dann alles nichts bringt, kannst du ja in einem neuen Thread nachfragen. Aber wir werden jetzt wohl kaum jeden Befehl einzeln durchkauen.
Es ist ja jetzt nicht so, daß das ein furchtbar komplexer Code wäre. Ein bisschen Eigeninitiative muss schon da sein.

Cu,
Udontknow
Anja Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

WIN xp

BeitragVerfasst: Mo 26.05.03 14:20 
bin ja shcon dabei in der hilfe zu schauen schreib mir raus was das heißt.

Ich danke eufch für eure mühe!

Gruß Anja
Anja Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 42

WIN xp

BeitragVerfasst: Di 27.05.03 09:54 
kann mal bitte jemand überprüfen ob ich das richtig intepretiert habe?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
function BinToHexa(text:string):string;  
// bekommt nen string mit namen text
const 
    symbole='0123456789ABCDEF';
// bezeichnet die constanten die unten verwendet werden
var BinValues:String; 
var i:integer; 
begin 
  Result:=''; 
  //Start bei letzter Ziffer 
  i:=length(text);
// länge des strings
  repeat 
// erste schleife beginn
    BinValues:=''; 
    repeat 
      //Aktuelle binäre Ziffer nehmen 
      BinValues:=Text[i]+BinValues; 
      //nächste Ziffer (Position ändern)
      Dec(i); 
    until (i=0) or (Length(BinValues)=4); // ausführen bis 4 zeichen eingelesen oder string zu ende
    //Entsprechendes Hex-Zeichen hinzufügen 
    Result:=Symbole[HexValue(BinValues)+1]+Result;// erzeugtem string entsprechendes symbol aus den konstatnen hin zu fügen 
  until i=0;// endgültiger abbruch weil string zu ende 
end;



Danke Anja
Udontknow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2596

Win7
D2006 WIN32, .NET (C#)
BeitragVerfasst: Di 27.05.03 09:59 
ja, denke, das ist in Ordnung.

Cu,
Udontknow
MaxiTB
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 679

Win2000, WinXp, Workbench ;-)
D7 Ent, VS2003 Arch.
BeitragVerfasst: Di 27.05.03 10:00 
Titel: Hehe
In kommentieren scheinst du ein Talent zu sein; ich rate zu einer Karriere im mittleren Managment. :twisted:

_________________
Euer Mäxchen
Wer früher stirbt, ist länger tot.