Ich habe mich auch mal an einem programm versucht, und bin gescheitert, ich breuchte ebenfalls mal hilfe, es ist so simpel, weil ich es meiner klasse noch vorstellen muss, und die sowieso nix kapieren.
PS: ich bin noch nicht lange hier, und würde mic über schnelle antworten sehr freuen
Code:
//Primzahlen.cpp
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cstdlib>
using namespace std;
int main()
{
int Ivier = 0;
int Ieins = 12;
int Izwei = 2;
int Iwdh = 12;
int Idrei;
int Ianz;
int Ifuenf;
double Dvier;
double Dfuenf;
cout << "Moechten sie eine gewisse Anzahl(1) oder die Primzahlen bis zu einem gewissen Wert(2) ausgegeben haben?" << endl;
cin >> Ifuenf;
cout << "Bitte geben sie nun den Gewünschten Wert an: ";
cin >> Ianz;
cout << "1\n2\n3\n5\n7\n11" << endl;
if ( Ifuenf == 1 )
{
while ( Iwdh <= Ianz )
{
Iwdh++;
Idrei = Ieins / Izwei;
Dvier = Ieins / Izwei;
Dfuenf = Idrei / Dvier;
Ivier++;
if ( Dfuenf == 1 )
{
Ieins++;
Izwei = 2;
}
if ( Dfuenf > 1 )
{
if ( Ivier <= Ianz )
{
Izwei++;
}
if ( Ivier > Ianz )
{
cout << Ieins << endl;
Ieins++;
Izwei = 2;
}
}
if ( Dfuenf < 1 )
{
if ( Ivier <= Ianz )
{
Izwei++;
}
if ( Ivier > Ianz )
{
cout << Ieins << endl;
Ieins++;
Izwei = 2;
}
}
}
}
if ( Ifuenf == 2 )
{
while ( Ieins <= Ianz )
{
Idrei = Ieins / Izwei;
Dvier = Ieins / Izwei;
Dfuenf = Idrei / Dvier;
Ivier++;
if ( Dfuenf == 1 )
{
Ieins++;
Izwei = 2;
}
if ( Dfuenf < 1 )
{
if ( Ivier <= Ianz )
{
Izwei++;
}
if ( Ivier > Ianz )
{
cout << Ieins << endl;
Ieins++;
Izwei = 2;
}
}
if ( Dfuenf > 1 )
{
if ( Ivier <= Ianz )
{
Izwei++;
}
if ( Ivier > Ianz )
{
cout << Ieins << endl;
Ieins++;
Izwei = 2;
}
}
}
}
system("PAUSE");
return 0;
}
PS: ich bin noch nicht lange hier, und würde mic über schnelle antworten sehr freuen
