potrebujem tutu funkciu upravit aby vracala ukazovatel na miesto za poslednim naplnenim prvkom v poli
int fill_array(double * begin, double * end)
{
double temp;
int i;
for(i=0;i< Max; i++)
{
cout << "Zadajte hodnotu c." << (i+1) << ": ";
cin >> temp;
if (!cin)
{
cin.clear();
while(cin.get()!='\n')
continue;
cout << "Neplatny vstup, zadavanie ukoncene.\n";
break;
}
else if(temp < 0)
break;
*(begin+i)= temp;
}
cout << i;
return i;
}
a tu je cely program
#include <iostream>
using namespace std;
const int Max = 5;
double prosperites[Max];
int fill_array(double * begin, double * end);
void show_array(const double * begin, const double * end, int in);
void revalue(double r, double * begin, double * end);
int main()
{
int size = fill_array(prosperites, prosperites+Max);
show_array(prosperites, prosperites+size, size);
cout << "Zadajte koeficient prehodnotenia: ";
double factor;
cin >> factor;
revalue(factor, prosperites, prosperites+size);
show_array(prosperites, prosperites+size, size);
cout << "Hotovo.\n";
while(cin.get()!='\n');
while(cin.get()!='\n');
return 0;
}
int fill_array(double * begin, double * end)
{
double temp;
int i;
for(i=0;i< Max; i++)
{
cout << "Zadajte hodnotu c." << (i+1) << ": ";
cin >> temp;
if (!cin)
{
cin.clear();
while(cin.get()!='\n')
continue;
cout << "Neplatny vstup, zadavanie ukoncene.\n";
break;
}
else if(temp < 0)
break;
*(begin+i)= temp;
}
cout << i;
return i;
}
void show_array(const double * begin, const double * end, int in)
{
for(int i=0; i< in; i++)
{
cout << "Majetok c." << (i+1) << ": ";
cout << *(begin+i) << " Sk\n";
}
}
void revalue(double r, double * begin, double * end)
{
for(int i=0; i< Max; i++)
*(begin+i)*=r;
}