int main() { int n=10; int a[n]; int k[n]; bool b=true; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) k[i]=0; for (int i = 0; i < n; i++) k[a[i]-1]=k[a[i]-1]+1; for (int i = 0; i < n; i++) if (k[i] != 1) b=false; if (b) cout << "Yes" << "\n"; else cout << "No" << "\n"; return 0; }
using namespace std;
int main() {
int n=10;
int a[n];
int k[n];
bool b=true;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) k[i]=0;
for (int i = 0; i < n; i++) k[a[i]-1]=k[a[i]-1]+1;
for (int i = 0; i < n; i++)
if (k[i] != 1) b=false;
if (b) cout << "Yes" << "\n";
else cout << "No" << "\n";
return 0;
}
Пример:
2
5
8
1
4
7
9
6
3
10
Yes