Загрузить файлы в «/»
This commit is contained in:
97
task1.cpp
97
task1.cpp
@@ -1,20 +1,77 @@
|
||||
#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;
|
||||
}
|
||||
//#include <iostream>
|
||||
//
|
||||
//using namespace std;
|
||||
//
|
||||
//int main() {
|
||||
// int s;
|
||||
// cout << "Size: ";
|
||||
// cin >> s;
|
||||
// int t;
|
||||
// cout << "Shape (1-left,2-right,3-up,4-down,5-square): ";
|
||||
// cin >> t;
|
||||
// if (s < 1) return 0;
|
||||
// switch (t) {
|
||||
// case 1: {
|
||||
// int i;
|
||||
// int j;
|
||||
// for (i = 1; i <= s; i++) {
|
||||
// for (j = 1; j <= i; j++) cout << "*";
|
||||
// cout << "\n";
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case 2: {
|
||||
// int i;
|
||||
// int j;
|
||||
// for (i = 1; i <= s; i++) {
|
||||
// for (j = 1; j <= s - i; j++) cout << " ";
|
||||
// for (j = 1; j <= i; j++) cout << "*";
|
||||
// cout << "\n";
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case 3: {
|
||||
// int i;
|
||||
// int j;
|
||||
// int k;
|
||||
// for (i = 1; i <= s; i++) {
|
||||
// for (j = 1; j <= s - i; j++) cout << " ";
|
||||
// for (k = 1; k <= 2 * i - 1; k++) cout << "*";
|
||||
// cout << "\n";
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case 4: {
|
||||
// int i;
|
||||
// int j;
|
||||
// int k;
|
||||
// for (i = s; i >= 1; i--) {
|
||||
// for (j = 1; j <= s - i; j++) cout << " ";
|
||||
// for (k = 1; k <= 2 * i - 1; k++) cout << "*";
|
||||
// cout << "\n";
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// case 5: {
|
||||
// int i;
|
||||
// int j;
|
||||
// int k;
|
||||
// for (i = s; i >= 1; i--) {
|
||||
// for (j = 1; j <= s - i; j++) cout << " ";
|
||||
// for (k = 1; k <= 2 * i - 1; k++) cout << "*";
|
||||
// cout << "\n";
|
||||
// }
|
||||
// for (i = 1; i <= s; i++) {
|
||||
// for (j = 1; j <= s - i; j++) cout << " ";
|
||||
// for (k = 1; k <= 2 * i - 1; k++) cout << "*";
|
||||
// cout << "\n";
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// default: {
|
||||
// cout << "Wrong choice\n";
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// return 0;
|
||||
//}
|
||||
Reference in New Issue
Block a user