Untitled
#include <bits/stdc++.h> using namespace std; int main() { vector<int> v; int x; for (int i = 0; i < 5; i++) { cin >> x; v.push_back(x); } vector<int> sv; sv = v; sort(sv.begin(), sv.end()); int count = 0; for (int i = 0; i < v.size(); i++) { if (v[i] != sv[i]) count++; } if (count == 2) cout << "YES" << endl; else cout << "NO" << endl; return 0; }
Leave a Comment