zwracanie wskaźnika elementu znajdującego się za ostatnim wypełnionym elementem
Ostatnio zmodyfikowano 2017-05-21 18:03
Chowan |
» 2017-05-21 18:03:22 odkopuje, bo robię to samo #include <iostream> const int Max = 5;
double * fill_array( double * begin, double * end ) { using namespace std; double * p = begin; int temp, i = 0; for( p; p != end; p++ ) { cout << "Podaj wartosc" << i + 1 << ", "; cin >> temp; if( !cin ) { cin.clear(); while( cin.get() != '\n' ) continue; cout << "bledne dane, wprowadzanie danych przerwane.\n"; break; } else if( temp < 0 ) break; begin[ i ] = temp; i++; } return begin + i; } void show_array( double * begin, double * end ) { using namespace std; double * p = begin; int i = 0; for( p; p != end; p++, i++ ) cout << "Nieruchomosc nr " << i + 1 << ": " << begin[ i ] << endl; } void revalue( double r, double * begin, double * end ) { double * p = begin; for( p; p != end; p++ ) { * p *= r; } } int main() { using namespace std; double properties[ Max ]; double * size = fill_array( properties, properties + Max ); show_array( properties, size ); if( * size > 0 ) { cout << "Podaj czynnik zminy wartosci: "; double factor; while( !( cin >> factor ) ) { cin.clear(); while( cin.get() != '\n' ) continue; cout << "Niepoprawna wartosc; podaj liczbe: "; } revalue( factor, properties, size ); show_array( properties, size ); } cout << "Gotowe.\n"; cin.get(); cin.get(); return 0; }
|
|
1 « 2 » |