Autor Beitrag
ProgrammerGirl
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17


D6
BeitragVerfasst: Sa 06.03.04 11:19 
Hi! Ich muss ein Programm Programmieren. Aber ich weiß nicht wie...
Kann mir einer helfen?

Moderiert von user profile iconPeter Lustig: Topic verschoben
StefanH
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1144

Win XP
D5 Standard, D7 Pers, D2005 Pers
BeitragVerfasst: Sa 06.03.04 11:35 
ööööööööööhm... na klar kann man dir helfen, bloß "ein programm programmieren" kann sehr viel sein.

es besteht ein kleiner unterschied zwischen einem Editor und einem PhotoShop - Clone :roll:

alo: Mehr infos... ;-)

_________________
"Als es noch keine Computer gab, war das Programmieren noch relativ einfach."(Edsger W. Dijkstra)
"Ich bin nicht von Sinnen, sondern ich rede wahre und vernünftige Worte." (Paulus)
BungeeBug
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 901



BeitragVerfasst: Sa 06.03.04 11:46 
Hi,

erst mal Hallo im Delphi - Forum.

1) Du musst uns schon sagen was du vor hast, dann können wir dir helfen.
2) Du solltest dir auch überlegen, in welchem Forum / in welcher Kategorie du dein Problem unterbringst.
ProgrammerGirl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17


D6
BeitragVerfasst: Sa 06.03.04 11:52 
Eingabe von 2 natürlichen Zahlen a und b
____________________________________
Ergebnis:= 0
____________________________________
bis a = 0


(a mod 2) = 1


Nein Ja

| Ergebnis:= Ergebnis + b

___________________________________________

a:= a DIV 2

b:= b*2
____________________________________________
Anzeige Ergebnis
BungeeBug
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 901



BeitragVerfasst: Sa 06.03.04 12:02 
Hi,

ich kann der Aufgabenstellung nicht ganz folgen. Kannst du evl. beschreiben was das Programm machen soll, wenn es denn fertig ist?
ProgrammerGirl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17


D6
BeitragVerfasst: Sa 06.03.04 12:35 
es gibt 2 natürliche zahlen a und b
das ergebnis ist 0
da ist dann eine schleife die geht bis a = 0 ist
wenn (a mod 2) = 1 ist, dann ist das Ergebnis = Ergebnis +b
wenn (a mod 2) = nicht 1 ist ,dann macht es nichts

dann müssen wir
a durch 2 dividieren
und b mit 2 multiplizieren

(und das immer wiederholen bis a = 0 ist)

(das ergebnis ist aber a*b)
aber wie programmier ich das ganze ...
ixtreme
Gast
Erhaltene Danke: 1



BeitragVerfasst: Sa 06.03.04 12:38 
sollen alle zwischenergebnisse auch angezeigt werden?


ixtreme.de
ProgrammerGirl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17


D6
BeitragVerfasst: Sa 06.03.04 12:42 
nein

ich glaub man kann das mit repeat oder while machen
und mit if

Moderiert von user profile iconPeter Lustig: Doppelpost gelöscht
Popov
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 1655
Erhaltene Danke: 13

WinXP Prof.
Bei Kleinigkeiten D3Pro, bei größeren Sachen D6Pro oder D7
BeitragVerfasst: Sa 06.03.04 13:10 
@ProgrammerGirl

Um etwas zu programmieren sollte man zuerst wissen was programmieren ist. Wenn du es nicht weißt, dann las es und stell keine blöden Fragen in Programmierer Foren. Selten eine so blöde Frage gelesen:

Zitat:
Hi! Ich muss ein Programm Programmieren. Aber ich weiß nicht wie...
Kann mir einer helfen?


1A Aufgabenstellung und noch bessere Frage.

_________________
Popov
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 06.03.04 13:23 
@Popov: bitte halte Dich mit Deinem Tonfall etwas zurück. Danke!

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
ProgrammerGirl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17


D6
BeitragVerfasst: Sa 06.03.04 13:32 
sorry
BungeeBug
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 901



BeitragVerfasst: Sa 06.03.04 13:42 
Hi,

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:
program mathe;

{$APPTYPE CONSOLE}

// Variablen
var
 a,b : integer; // A und B ( natürliche Zahl )
 ergebniss : integer; // Das Ergebniss

// Hauptprogramm
begin
 ergebniss := 0; // Ergebniss auf 0 setzen
 Write('Bitte A angeben : ');readln(a); // A einlesen
 Write('Bitte B angeben : ');readln(b); // B einlesen
 
repeat
 if (a mod 2) = 1 then // Wenn (a mod 2) dann
  begin
   ergebniss := ergebniss +b;
  end;
 {A * 2}
  a :=  a*2;
 {B / 2}
  b :=  b div 2;
 {Ergebniss ausgeben}
 writeln('A : ', a); // A ausgeben
 writeln('B : ', b); // B ausgeben
 writeln('Ergebniss : ', ergebniss); // Ergebniss ausgeben
until a = 0;

end.


So sollte es gehen. Nur wirst du nich drum herum kommen das Programmiern zulernen.

P.S.: Das ist alles aus dem Kopf und und nicht getestet. Sollte aber funktioniern.
ProgrammerGirl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17


D6
BeitragVerfasst: Sa 06.03.04 17:29 
ich hab das einmal selbst versucht
ich hab 1 button
2 edit felder
und 1 panel

aber ich mach da einen großen fehler
ich aber nur nicht welchen und komm auch nicht weiter


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:
procedure TForm1.BtErgebnisClick(Sender: TObject);
var Ergebnis, a, b: integer;
begin
  a:=StrToInt (Edit1.Text);
  b:=StrToInt (Edit2.Text);
  Ergebnis:=0;

  while  a = 0 do
  if a MOD 2 = 1
  then begin
    Ergebnis:= Ergebnis + b;
    a:= a mod 2;
    b:= b*2;
  end
  else
  begin
    a:= a DIV 2;
    b:= 2*b;
  end;
end;
begin
  Panel1.Caption:=Ergebnis;
end.


Moderiert von user profile iconPeter Lustig: Delphi-Tags hinzugefügt und Code eingerückt
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Sa 06.03.04 17:46 
Kann es sein, dass die schleife nie abgearbeitet wird, wenn am Anfang a schon ungleich Null ist?
Jack Falworth
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 222

Win XP Pro, Slackware 10.0
D5 Enterprise, C++, ABAP
BeitragVerfasst: Sa 06.03.04 18:03 
genau wie luckie sagt. Vielleicht sollte es dann heißen
ausblenden Delphi-Quelltext
1:
2:
3:
4:
  while a <> 0 do  // solange a ungleich 0 ist
  begin
   ...
  end;


und dann noch ein kleiner fehler am Schluss:

ProgrammerGirl hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
end;
begin
  Panel1.Caption:=Ergebnis;
end.


das "begin" muss gelöscht werden und das end mit semikolon hinter die panel anweisung also, insgesamt:

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:
procedure TForm1.BtErgebnisClick(Sender: TObject);
var Ergebnis, a, b: integer;
begin
  a:=StrToInt (Edit1.Text);
  b:=StrToInt (Edit2.Text);
  Ergebnis:=0;

  while  a <span style="color: red"><></span> 0 do
  if a MOD 2 = 1
  then begin
    Ergebnis:= Ergebnis + b;
    a:= a mod 2;
    b:= b*2;
  end
  else
  begin
    a:= a DIV 2;
    b:= 2*b;
  end;
Panel1.Caption:=Ergebnis;
<span style="color: red">end;</span>
  
end.


So sollte es eigentlich klappen. ich habs mir nur kurz angeschaut, also keine garantie :)

_________________
Andere zu kritisieren ist mitunter eine Möglichkeit, sich selbst ins bessere Licht zu setzen.
ProgrammerGirl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17


D6
BeitragVerfasst: Sa 06.03.04 18:12 
funktioniert immer noch nicht

ich glaub das end; am Ende kommt nicht
trotzdem geht es nicht

{am schluss}

[Fehler] Unit1.pas(55): Deklaration erwartet, aber Bezeichner 'Panel1' gefunden
Killmag10
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 297

Suse Linux / DOS / Windows All In One ;)
D4 / D2005
BeitragVerfasst: Sa 06.03.04 18:53 
Hi hab in Fehler gefunden ist aber nicht der von dir... glaub ich zumindest.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TForm1.BtErgebnisClick(Sender: TObject);
var Ergebnis, a, b: integer;
begin
  a:=StrToInt (Edit1.Text);
  b:=StrToInt (Edit2.Text);
  Ergebnis:=0;

  while  a <> 0 do
  if a MOD 2 = 1
  then begin
    Ergebnis:= Ergebnis + b;
    a:= a mod 2;
    b:= b*2; 
  end
  else
  begin
    a:= a DIV 2;
    b:= 2*b;
  end;
Panel1.Caption:=inttostr(Ergebnis);
end;


Panel1.Caption:=inttostr(Ergebnis);
Zahl nix Text :wink:

mfg. Killmag10

_________________
Mega-inkompetente Computer-ruinierende Organisation spioniert ohne funktionierende Technik
ProgrammerGirl Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17


D6
BeitragVerfasst: Sa 06.03.04 19:28 
das geht trotzdem irgenwie nicht

Panel1.Caption:=inttostr(Ergebnis);

[Fehler] Unit1.pas(55): Deklaration erwartet, aber Bezeichner 'Panel1' gefunden
Jack Falworth
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 222

Win XP Pro, Slackware 10.0
D5 Enterprise, C++, ABAP
BeitragVerfasst: Sa 06.03.04 19:52 
also die Prozedure ist völlig korrekt.
Der Fehler muss dann in einer procedure vor oder danach sein.
Hast wohl irgendwo ein end; zuviel oder zuwenig.

MfG
Jack Falworth

_________________
Andere zu kritisieren ist mitunter eine Möglichkeit, sich selbst ins bessere Licht zu setzen.
Killmag10
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 297

Suse Linux / DOS / Windows All In One ;)
D4 / D2005
BeitragVerfasst: Sa 06.03.04 20:26 
Poste mal am besten deine ganze unit :wink:

_________________
Mega-inkompetente Computer-ruinierende Organisation spioniert ohne funktionierende Technik


Zuletzt bearbeitet von Killmag10 am Sa 06.03.04 20:46, insgesamt 1-mal bearbeitet
Dieses Thema ist gesperrt, Du kannst keine Beiträge editieren oder beantworten.

Das Thema wurde von einem Team-Mitglied geschlossen. Wenn du mit der Schließung des Themas nicht einverstanden bist, kontaktiere bitte das Team.