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{ 14 };
- double K[n]{};
- int i{}, is_ordered{ 1 };
- for (i = 0; i <= n - 1; i++) {
- while (true) {
- cout << "K[" << i << "] = ";
- cin >> K[i];
- if (cin.fail()) {
- cin.clear();
- cin.ignore(32767, '\n');
- cout << "Число було введено неправильно. Спробуйте ще раз!" << endl;
- continue;
- }
- else {
- break;
- }
- }
- }
- for (i = 0; i <= n - 2; i++) {
- if (K[i] > K[i + 1]) {
- is_ordered = 0;
- break;
- }
- }
- if (is_ordered == 1) {
- cout << "Масив є упорядкованим" << endl;
- }
- else {
- cout << "Масив не є упорядкованим" << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement