Все написал, но инвертировать массив так и не получилось .
Вот сами исходники проги:
CODE
#include <iostream>
using namespace std;
short Fill_array(double array[], short size);
void Show_array(const double array[], short size);
void Reverse_array(double array[],short size);
int main()
{
double array[20];
short size=Fill_array(array,20);
Reverse_array(array,size);
Show_array(array,size);
return 0;
}
short Fill_array(double array[], short size)
{
for(short a=0;a<size;a++)
{
cout<<"\nINPUT NUMBER: ";
short temp;
if(!(cin>>temp))
{
cin.clear();
while(cin.get()!='\n')
continue;
cout<<"\nBad Input\n\n";
break;
}
array[a]=temp;
}
return a;
}
void Show_array(const double array[], short size)
{
for(short a=0;a<size;a++)
cout<<"\n"<<array[a]<<endl;
}
void Reverse_array(double array[],short size)
{
short a,b;
double temp_array;
for (a=0,b=size-1;a<size;a++,b--)
{
temp_array=array[a];
array[a]=array[b];
array[b]=temp_array;
}
}
using namespace std;
short Fill_array(double array[], short size);
void Show_array(const double array[], short size);
void Reverse_array(double array[],short size);
int main()
{
double array[20];
short size=Fill_array(array,20);
Reverse_array(array,size);
Show_array(array,size);
return 0;
}
short Fill_array(double array[], short size)
{
for(short a=0;a<size;a++)
{
cout<<"\nINPUT NUMBER: ";
short temp;
if(!(cin>>temp))
{
cin.clear();
while(cin.get()!='\n')
continue;
cout<<"\nBad Input\n\n";
break;
}
array[a]=temp;
}
return a;
}
void Show_array(const double array[], short size)
{
for(short a=0;a<size;a++)
cout<<"\n"<<array[a]<<endl;
}
void Reverse_array(double array[],short size)
{
short a,b;
double temp_array;
for (a=0,b=size-1;a<size;a++,b--)
{
temp_array=array[a];
array[a]=array[b];
array[b]=temp_array;
}
}
В частности вопросы возьникают по функции Reverse_array. Что в ней не так?