CPP 201
Verfasst: 04.05.09 20:38
Hallo zusammen,
ich habe hier mal wieder ein Problem:
Das Programm beginnt sofort mit "Bitte drücken Sie eine taste" und bricht dann ab.
Was ist hier das Problem?
Ich benutze Dev C++.
#include <iostream>
#include <stdio.h>
#include <conio.h>
using namespace std;
int main()
{int akGeld[6] = { 50, 20, 10, 5, 2, 1 };
int kBetrag = 0;
int kSumme = 0;
int kTemp = 0;
// Betrag einlesen
cout << "Betrag: "; cin >> kBetrag;
// Eingabe prüfen
if (kBetrag >= 100)
{
cout << "Es sind nur Betraege < 100 erlaubt!" << endl;
system("PAUSE");
return 0;
}
// Ausgabe
cout << "Stueckelung: ";
for (int k = 0; k < 6; k++)
{
if (kBetrag != akGeld[k])
{
int kCount = kTemp / akGeld[k];
if (kCount > 0)
cout << kCount << "*" << akGeld[k] << " ";
kSumme += kTemp / akGeld[k] * akGeld[k];
kTemp %= akGeld[k];
}
}
// Summe ausgeben
cout << "Summe: " << kSumme << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
ich habe hier mal wieder ein Problem:
Das Programm beginnt sofort mit "Bitte drücken Sie eine taste" und bricht dann ab.
Was ist hier das Problem?
Ich benutze Dev C++.
#include <iostream>
#include <stdio.h>
#include <conio.h>
using namespace std;
int main()
{int akGeld[6] = { 50, 20, 10, 5, 2, 1 };
int kBetrag = 0;
int kSumme = 0;
int kTemp = 0;
// Betrag einlesen
cout << "Betrag: "; cin >> kBetrag;
// Eingabe prüfen
if (kBetrag >= 100)
{
cout << "Es sind nur Betraege < 100 erlaubt!" << endl;
system("PAUSE");
return 0;
}
// Ausgabe
cout << "Stueckelung: ";
for (int k = 0; k < 6; k++)
{
if (kBetrag != akGeld[k])
{
int kCount = kTemp / akGeld[k];
if (kCount > 0)
cout << kCount << "*" << akGeld[k] << " ";
kSumme += kTemp / akGeld[k] * akGeld[k];
kTemp %= akGeld[k];
}
}
// Summe ausgeben
cout << "Summe: " << kSumme << endl;
system("PAUSE");
return EXIT_SUCCESS;
}