Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- using namespace std;
- int main()
- {
- SetConsoleOutputCP(1251);
- auto const n{ 7 };
- int i{};
- int x[n]{}, y[n]{};
- for (i = 0; i < n; i++) {
- while (true) {
- cout << "x[" << i << "] = ";
- cin >> x[i];
- if (cin.fail() || cin.peek() != '\n' || x[i] < 10 || x[i] > 99) {
- cin.clear();
- cin.ignore(32767, '\n');
- cout << "Число було введено неправильно. Спробуйте ще раз!" << endl;
- continue;
- }
- else {
- break;
- }
- }
- }
- cout << "Вихідний масив:" << endl;
- for (i = 0; i < n; i++) {
- cout << x[i] << " ";
- y[i] = x[i] / 10;
- }
- cout << endl << "Новий масив:" << endl;
- for (i = 0; i < n; i++) {
- cout << y[i] << " ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement