Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- const int Max = 5;
- int fill_array(double * begin, const double * end);
- void show_array(const double * begin, const double * end);
- void revalue(double r, double * begin, const double * end);
- int main ()
- {
- using namespace std;
- double properties[Max];
- int size = fill_array(properties, (properties + Max));
- show_array(properties, (properties + size));
- if (size > 0)
- {
- cout << "Enter revaluation factor: ";
- double factor;
- while (!(cin >> factor))
- {
- cin.clear ();
- while (cin.get() != '\n')
- continue;
- cout << "Bad input; Please enter a number: ";
- }
- revalue(factor, properties, (properties + size));
- show_array(properties, (properties + size));
- }
- cout << "Done.\n";
- cin.get ();
- cin.get ();
- return 0;
- }
- int fill_array(double * begin, const double * end)
- {
- using namespace std;
- double temp;
- int i;
- for (double * pt = begin, i; pt != end ; pt++, i++)
- {
- cout << "Enter value #" << (i + 1) << ": ";
- cin >> temp;
- if (!cin)
- {
- cin.clear();
- while (cin.get() != '\n')
- continue;
- cout << "Bad input; input process terminated.\n";
- break;
- }
- else if (temp < 0)
- {
- break;
- }
- *pt = temp;
- }
- return i;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement