Загрузить файлы в «/»
This commit is contained in:
20
task1.cpp
Normal file
20
task1.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
cout << "Enter a four-digit number: ";
|
||||
cin >> n;
|
||||
|
||||
if (n < 1000 || n > 9999) {
|
||||
cout << "Error! This is not a four-digit number." << endl;
|
||||
} else {
|
||||
int a = n / 1000;
|
||||
int b = (n / 100) % 10;
|
||||
int c = (n / 10) % 10;
|
||||
int d = n % 10;
|
||||
int r = c * 1000 + d * 100 + a * 10 + b;
|
||||
cout << "Result: " << r << endl;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user