-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTask3Week3.cpp
36 lines (31 loc) · 1.05 KB
/
Task3Week3.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
using namespace std;
int main() {
int num;
cout << "Enter number: ";
cin >> num;
int first, second, third, fourth;
// num <= 9999 -> [1000, 9999]
// това беше излишна проверка, може директно да проверим така
if (num >= 1000 && num <= 9999) {
fourth = num % 10;
num /= 10;
third = num % 10;
num /= 10;
second = num % 10;
first = num / 10;
bool hasUniqueDigits = (first != second) &&
(second != third) &&
(third != fourth) &&
(fourth != first) &&
(first != third) &&
(second != fourth);
if (hasUniqueDigits) {
cout << "YES, all the numbers are different!" << endl;
} else {
cout << "NO, not all numbers are different!" << endl;
}
} else {
cout << "Number is not 4 digits" << endl;
}
}