<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Matheprojekt Verbesserungsvorschläger erwünscht]]></title><description><![CDATA[<p>Hi<br />
ich schreibe gerade an einem Matheprogramm, das mir automatisch die Formeln vom logistischen Wachstum angibt<br />
ich verwende absichtlich keine schleife</p>
<p>hier mein quelltext</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
const String Dateiname = &quot;Formeln.txt&quot;;
TForm1 *Form1;
float k, Bestand, Ergebnis, Schranke;
TStringList *Formeln   ;
int Nr;
bool Nochmal, sicher;
String Ausgabe;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
                   Nr = 0;
                   Nochmal = false;
                   Formeln = new TStringList;

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{  //Aufnahme der Werte
 try {

if (Nochmal != true)   //wenn der Knopf nicht auf Nochmal umgestellt ist
{  k = atof(Edit1-&gt;Text.c_str());
Bestand = atof(Edit2-&gt;Text.c_str());
Schranke = atof(Edit3-&gt;Text.c_str());

Button1-&gt;Caption = &quot;Weiter gehts&quot;;
Nochmal = true;
                            //Vorbereiten des Buttons nochmal
sicher = false;

Ergebnis = k*Bestand*(Schranke -Bestand);
// Alte Formel
   Ausgabe = &quot;B(1)= &quot;+ FloatToStrF(k,ffNumber,8,6)+&quot;*&quot;+ FloatToStrF(Bestand,ffNumber,8,6)+&quot;*(&quot;+ FloatToStrF(Schranke,ffNumber,8,6)+ &quot; - &quot; + FloatToStrF(Bestand,ffNumber,8,6)+ &quot;) = &quot; + FloatToStrF(Ergebnis,ffNumber,8,6);
Panel4-&gt;Caption= Ausgabe;
Formeln-&gt;Add(Ausgabe) ;
Bestand  = Ergebnis;
Nr++;
Ausgabe = &quot;B(&quot;+ String(Nr)+&quot;)=&quot; + FloatToStrF(k,ffNumber,8,6)+&quot;*&quot;+ FloatToStrF(Bestand,ffNumber,8,6)+&quot;*(&quot;+ FloatToStrF(Schranke,ffNumber,8,6)+ &quot; - &quot; + FloatToStrF(Bestand,ffNumber,8,6)+&quot;)&quot;;
Panel5-&gt;Caption = &quot;Neue Formel:&quot; + Ausgabe;
Formeln-&gt;Add(Ausgabe) ;

}
if (Nochmal)
{
    Ergebnis = k*Bestand*(Schranke -Bestand);
// Alte Formel
Ausgabe = &quot;B(&quot;+ String(Nr)+&quot;)=&quot;+ FloatToStrF(k,ffNumber,8,6)+&quot;*&quot;+ FloatToStrF(Bestand,ffNumber,8,6)+&quot;*(&quot;+ FloatToStrF(Schranke,ffNumber,8,6)+ &quot; - &quot; + FloatToStrF(Bestand,ffNumber,8,6)+ &quot;) = &quot; + FloatToStrF(Ergebnis,ffNumber,8,6);
Panel4-&gt;Caption=  Ausgabe  ;
Formeln-&gt;Add(Ausgabe) ;
Bestand  = Ergebnis;
Nr++;
Ausgabe = &quot;B(&quot;+ String(Nr)+&quot;)=&quot; + FloatToStrF(k,ffNumber,8,6)+&quot;*&quot;+ FloatToStrF(Bestand,ffNumber,8,6)+&quot;*(&quot;+ FloatToStrF(Schranke,ffNumber,8,6)+ &quot; - &quot; + FloatToStrF(Bestand,ffNumber,8,6)+&quot;)&quot;;
Panel5-&gt;Caption = &quot;Neue Formel:&quot;+Ausgabe;
Formeln-&gt;Add(Ausgabe) ;
   }
}
catch (...)
{
Application-&gt;MessageBox (&quot;Fehler jeglicher Art!&quot;, &quot;Fehler&quot;, 0+16);
}

}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Edit1-&gt;Text=&quot;&quot;;
Edit2-&gt;Text = &quot;&quot;;
Edit3-&gt;Text = &quot;&quot;;
Panel4-&gt;Caption= &quot;B(1) = k*B(0)*(S-B(0)&quot;;
Panel5-&gt;Caption = &quot;&quot;;
Nr=0;
Nochmal=false;
Button1-&gt;Caption = &quot;OK&quot;;

}
//---------------------------------------------------------------------------
void __fastcall TForm1::Speichern1Click(TObject *Sender)
{
    try
  {
    if (SaveDialog1-&gt;Execute ())
    Formeln-&gt;SaveToFile(SaveDialog1-&gt;FileName) ;
    sicher = true;
    }

    catch (...)
    {    Application-&gt;MessageBox(&quot;Fehler beim Speichern der Datei!!&quot;, &quot;Fehler&quot;,0+16);
}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Drucken1Click(TObject *Sender)
{
     try
  {
    if (PrintDialog1-&gt;Execute ())
    {
      RichEdit1-&gt;Text = Formeln-&gt;Text ;
      RichEdit1-&gt;Print (&quot;Formeln&quot;) ;
    }
  }
  catch (...)
  {
    Application-&gt;MessageBox
      (&quot;Fehler beim Drucken der Datei!&quot;, &quot;Achtung!&quot;, 0+48);
  }
}
//---------------------------------------------------------------------------
</code></pre>
<p>jetzt würde ich aber gerne wissen wie es geht dass er zwar so viele stellen verarbeitet aber nicht immer die ganzen nuller hinten angibt</p>
<p>Vielen Dank für eure Hilfe!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/232835/matheprojekt-verbesserungsvorschläger-erwünscht</link><generator>RSS for Node</generator><lastBuildDate>Fri, 25 Sep 2026 04:40:05 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/232835.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Jan 2009 20:51:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Matheprojekt Verbesserungsvorschläger erwünscht on Tue, 27 Jan 2009 20:51:09 GMT]]></title><description><![CDATA[<p>Hi<br />
ich schreibe gerade an einem Matheprogramm, das mir automatisch die Formeln vom logistischen Wachstum angibt<br />
ich verwende absichtlich keine schleife</p>
<p>hier mein quelltext</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------

#include &lt;vcl.h&gt;
#pragma hdrstop

#include &quot;Unit1.h&quot;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource &quot;*.dfm&quot;
const String Dateiname = &quot;Formeln.txt&quot;;
TForm1 *Form1;
float k, Bestand, Ergebnis, Schranke;
TStringList *Formeln   ;
int Nr;
bool Nochmal, sicher;
String Ausgabe;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
                   Nr = 0;
                   Nochmal = false;
                   Formeln = new TStringList;

}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{  //Aufnahme der Werte
 try {

if (Nochmal != true)   //wenn der Knopf nicht auf Nochmal umgestellt ist
{  k = atof(Edit1-&gt;Text.c_str());
Bestand = atof(Edit2-&gt;Text.c_str());
Schranke = atof(Edit3-&gt;Text.c_str());

Button1-&gt;Caption = &quot;Weiter gehts&quot;;
Nochmal = true;
                            //Vorbereiten des Buttons nochmal
sicher = false;

Ergebnis = k*Bestand*(Schranke -Bestand);
// Alte Formel
   Ausgabe = &quot;B(1)= &quot;+ FloatToStrF(k,ffNumber,8,6)+&quot;*&quot;+ FloatToStrF(Bestand,ffNumber,8,6)+&quot;*(&quot;+ FloatToStrF(Schranke,ffNumber,8,6)+ &quot; - &quot; + FloatToStrF(Bestand,ffNumber,8,6)+ &quot;) = &quot; + FloatToStrF(Ergebnis,ffNumber,8,6);
Panel4-&gt;Caption= Ausgabe;
Formeln-&gt;Add(Ausgabe) ;
Bestand  = Ergebnis;
Nr++;
Ausgabe = &quot;B(&quot;+ String(Nr)+&quot;)=&quot; + FloatToStrF(k,ffNumber,8,6)+&quot;*&quot;+ FloatToStrF(Bestand,ffNumber,8,6)+&quot;*(&quot;+ FloatToStrF(Schranke,ffNumber,8,6)+ &quot; - &quot; + FloatToStrF(Bestand,ffNumber,8,6)+&quot;)&quot;;
Panel5-&gt;Caption = &quot;Neue Formel:&quot; + Ausgabe;
Formeln-&gt;Add(Ausgabe) ;

}
if (Nochmal)
{
    Ergebnis = k*Bestand*(Schranke -Bestand);
// Alte Formel
Ausgabe = &quot;B(&quot;+ String(Nr)+&quot;)=&quot;+ FloatToStrF(k,ffNumber,8,6)+&quot;*&quot;+ FloatToStrF(Bestand,ffNumber,8,6)+&quot;*(&quot;+ FloatToStrF(Schranke,ffNumber,8,6)+ &quot; - &quot; + FloatToStrF(Bestand,ffNumber,8,6)+ &quot;) = &quot; + FloatToStrF(Ergebnis,ffNumber,8,6);
Panel4-&gt;Caption=  Ausgabe  ;
Formeln-&gt;Add(Ausgabe) ;
Bestand  = Ergebnis;
Nr++;
Ausgabe = &quot;B(&quot;+ String(Nr)+&quot;)=&quot; + FloatToStrF(k,ffNumber,8,6)+&quot;*&quot;+ FloatToStrF(Bestand,ffNumber,8,6)+&quot;*(&quot;+ FloatToStrF(Schranke,ffNumber,8,6)+ &quot; - &quot; + FloatToStrF(Bestand,ffNumber,8,6)+&quot;)&quot;;
Panel5-&gt;Caption = &quot;Neue Formel:&quot;+Ausgabe;
Formeln-&gt;Add(Ausgabe) ;
   }
}
catch (...)
{
Application-&gt;MessageBox (&quot;Fehler jeglicher Art!&quot;, &quot;Fehler&quot;, 0+16);
}

}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Edit1-&gt;Text=&quot;&quot;;
Edit2-&gt;Text = &quot;&quot;;
Edit3-&gt;Text = &quot;&quot;;
Panel4-&gt;Caption= &quot;B(1) = k*B(0)*(S-B(0)&quot;;
Panel5-&gt;Caption = &quot;&quot;;
Nr=0;
Nochmal=false;
Button1-&gt;Caption = &quot;OK&quot;;

}
//---------------------------------------------------------------------------
void __fastcall TForm1::Speichern1Click(TObject *Sender)
{
    try
  {
    if (SaveDialog1-&gt;Execute ())
    Formeln-&gt;SaveToFile(SaveDialog1-&gt;FileName) ;
    sicher = true;
    }

    catch (...)
    {    Application-&gt;MessageBox(&quot;Fehler beim Speichern der Datei!!&quot;, &quot;Fehler&quot;,0+16);
}
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Drucken1Click(TObject *Sender)
{
     try
  {
    if (PrintDialog1-&gt;Execute ())
    {
      RichEdit1-&gt;Text = Formeln-&gt;Text ;
      RichEdit1-&gt;Print (&quot;Formeln&quot;) ;
    }
  }
  catch (...)
  {
    Application-&gt;MessageBox
      (&quot;Fehler beim Drucken der Datei!&quot;, &quot;Achtung!&quot;, 0+48);
  }
}
//---------------------------------------------------------------------------
</code></pre>
<p>jetzt würde ich aber gerne wissen wie es geht dass er zwar so viele stellen verarbeitet aber nicht immer die ganzen nuller hinten angibt</p>
<p>Vielen Dank für eure Hilfe!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1653502</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1653502</guid><dc:creator><![CDATA[Iloveyouworm]]></dc:creator><pubDate>Tue, 27 Jan 2009 20:51:09 GMT</pubDate></item><item><title><![CDATA[Reply to Matheprojekt Verbesserungsvorschläger erwünscht on Tue, 27 Jan 2009 21:51:32 GMT]]></title><description><![CDATA[<p>1. falsches Forum (kein standard c++)<br />
2. globale variablen sind hässlich - weiß ich aber nicht, wie man da in deinem fall drum rum kommen könnte - man könnte die variablen aber zumindest in eine klasse kapseln (falls es von der logik her hinkommen würde)<br />
3. code einrücken<br />
4. bezeichner wie k werden üblicherweise für for-schleifen und damit als int/size_t verwendet - auf jeden fall sollte man für varialben immer sprechende namen nehmen (außer in for-schleifen, wo man idR i-k nimmt) - erst recht, wenn diese global verwendet werden...</p>
<p>bb</p>
<p>edit: wieso verwendet du absichtlich keine schleifen? xD</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1653542</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1653542</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Tue, 27 Jan 2009 21:51:32 GMT</pubDate></item><item><title><![CDATA[Reply to Matheprojekt Verbesserungsvorschläger erwünscht on Tue, 27 Jan 2009 21:55:19 GMT]]></title><description><![CDATA[<p>unskilled schrieb:</p>
<blockquote>
<p>2. globale variablen sind hässlich - weiß ich aber nicht, wie man da in deinem fall drum rum kommen könnte - man könnte die variablen aber zumindest in eine klasse kapseln (falls es von der logik her hinkommen würde)</p>
</blockquote>
<p>Was ist denn so schlimm an globalen variablen bzw. warum sind sie hässlich?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1653546</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1653546</guid><dc:creator><![CDATA[Don Quijote]]></dc:creator><pubDate>Tue, 27 Jan 2009 21:55:19 GMT</pubDate></item><item><title><![CDATA[Reply to Matheprojekt Verbesserungsvorschläger erwünscht on Tue, 27 Jan 2009 22:03:41 GMT]]></title><description><![CDATA[<p>Don Quijote schrieb:</p>
<blockquote>
<p>Was ist denn so schlimm an globalen variablen bzw. warum sind sie hässlich?</p>
</blockquote>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/27a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--right_arrow"
      title=":arrow_right:"
      alt="➡"
    /> <a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-214549.html" rel="nofollow">Gründe gegen globale Variablen</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1653549</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1653549</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Tue, 27 Jan 2009 22:03:41 GMT</pubDate></item><item><title><![CDATA[Reply to Matheprojekt Verbesserungsvorschläger erwünscht on Tue, 27 Jan 2009 22:20:43 GMT]]></title><description><![CDATA[<p>Ok, vielen dank.</p>
<p>Ich sehe aber schon, das kommt immer auf den Umfang des Programms und die Verwendung der Variable an. M</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1653559</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1653559</guid><dc:creator><![CDATA[Don Quijote]]></dc:creator><pubDate>Tue, 27 Jan 2009 22:20:43 GMT</pubDate></item><item><title><![CDATA[Reply to Matheprojekt Verbesserungsvorschläger erwünscht on Tue, 27 Jan 2009 23:01:25 GMT]]></title><description><![CDATA[<p>Don Quijote schrieb:</p>
<blockquote>
<p>Ich sehe aber schon, das kommt immer auf den Umfang des Programms und die Verwendung der Variable an. M</p>
</blockquote>
<p>Ja, das stimmt schon. Bei kleinen Progrämmchen sind globale Variablen durchaus vertretbar. Je grösser das Projekt wird, desto gefährlicher werden sie allerdings. Meistens lassen sie sich aber gut vermeiden (jedoch nicht ganz immer)...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1653570</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1653570</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Tue, 27 Jan 2009 23:01:25 GMT</pubDate></item><item><title><![CDATA[Reply to Matheprojekt Verbesserungsvorschläger erwünscht on Wed, 28 Jan 2009 15:44:35 GMT]]></title><description><![CDATA[<p>unskilled schrieb:</p>
<blockquote>
<p>wieso verwendet du absichtlich keine schleifen? xD</p>
</blockquote>
<p>weil mein mathelehrer des so wollte</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1653933</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1653933</guid><dc:creator><![CDATA[Iloveyouworm]]></dc:creator><pubDate>Wed, 28 Jan 2009 15:44:35 GMT</pubDate></item></channel></rss>