Imam gresku u programu, gdje??
13.11.2006. u 11:56 · pre 242 meseci
#1
Potrebno je napisati program koji ce bilo koje cifre (max 50) ucitati i sortirane iscitati. Prilikom sortiranja potrebno je koristiti rekurzivni algoritam. Pored toga anci maximum i staviti ga na prvo mjesto liste. Gdje je greska?
#include <iostream>
using namespace std;
void sortiere(int a, int e);
int werte[]={34, -45, 2, 3, -4, 5, 1, -8, 9, 1, 23, 21};
char antw;
int main ()
{
start:
sortiere (0, size of (werte/4);
for (int r=0; r< sizeof(werte)/4; r++)
cout << werte [r]<< " ";
cout << "nocheinmal?: ";
cin >> antw;
if (antw == "n")
{
goto ende;
}
else
{
goto start;
}
ende;
return 0;
}
ende;
return 0;
}
if (a<e)
{
int gr =werte[a];
int zw;
int index;
for (int i=a; i<e; i++)
{
if (werte >gr)
gr=werte ;
index = i;
{
{
if (index!=0)
{
zw=werte [index];
werte [index] = werte [a];
werte [a]=zw;
}
sortierung (a+1), e);
}
}
#include <iostream>
using namespace std;
void sortiere(int a, int e);
int werte[]={34, -45, 2, 3, -4, 5, 1, -8, 9, 1, 23, 21};
char antw;
int main ()
{
start:
sortiere (0, size of (werte/4);
for (int r=0; r< sizeof(werte)/4; r++)
cout << werte [r]<< " ";
cout << "nocheinmal?: ";
cin >> antw;
if (antw == "n")
{
goto ende;
}
else
{
goto start;
}
ende;
return 0;
}
ende;
return 0;
}
if (a<e)
{
int gr =werte[a];
int zw;
int index;
for (int i=a; i<e; i++)
{
if (werte >gr)
gr=werte ;
index = i;
{
{
if (index!=0)
{
zw=werte [index];
werte [index] = werte [a];
werte [a]=zw;
}
sortierung (a+1), e);
}
}