#include <iostream>
using namespace std;
int main() {
int a, b, c, d;
// รับค่าให้ถูกต้องตามเงื่อนไข
while (true) {
cout << "Enter number 1: ";
cin >> a;
cout << "Enter number 2: ";
cin >> b;
cout << "Enter number 3: ";
cin >> c;
cout << "Enter number 4: ";
cin >> d;
if (a >= 1 && a <= 100 &&
b >= 1 && b <= 100 &&
c >= 1 && c <= 100 &&
d >= 1 && d <= 100 &&
a == c && b == d) {
break;
}
cout << "Invalid input, please try again.\n\n";
}
cout << "\nInput: " << a << ", " << b << ", " << c << ", " << d << endl;
// เดินเป็นสี่เหลี่ยม
cout << "Start: Walk straight ";
if (a == 1)
cout << "down ";
else
cout << "up ";
cout << a << " unit and turn left." << endl;
cout << "Walk straight for " << b << " units and turn left." << endl;
cout << "Walk straight ";
if (c == 1)
cout << "up ";
else
cout << "down ";
cout << c << " unit and turn left." << endl;
cout << "End: Walk straight for " << d << " units." << endl;
// วาดกรอบ
cout << "+++++++++++++++++++++++++\n";
cout << "Rectangular area = " << b << " * " << a
<< " = " << b * a << " unit\n";
cout << "+++++++++++++++++++++++++\n";
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7CiAgICBpbnQgYSwgYiwgYywgZDsKCiAgICAvLyDguKPguLHguJrguITguYjguLLguYPguKvguYnguJbguLnguIHguJXguYnguK3guIfguJXguLLguKHguYDguIfguLfguYjguK3guJnguYTguIIKICAgIHdoaWxlICh0cnVlKSB7CiAgICAgICAgY291dCA8PCAiRW50ZXIgbnVtYmVyIDE6ICI7CiAgICAgICAgY2luID4+IGE7CiAgICAgICAgY291dCA8PCAiRW50ZXIgbnVtYmVyIDI6ICI7CiAgICAgICAgY2luID4+IGI7CiAgICAgICAgY291dCA8PCAiRW50ZXIgbnVtYmVyIDM6ICI7CiAgICAgICAgY2luID4+IGM7CiAgICAgICAgY291dCA8PCAiRW50ZXIgbnVtYmVyIDQ6ICI7CiAgICAgICAgY2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IiB1bml0cy4iIDw8IGVuZGw7CgogICAgLy8g4Lin4Liy4LiU4LiB4Lij4Lit4LiaCiAgICBjb3V0IDw8ICIrKysrKysrKysrKysrKysrKysrKysrKysrXG4iOwogICAgY291dCA8PCAiUmVjdGFuZ3VsYXIgYXJlYSA9ICIgPDwgYiA8PCAiICogIiA8PCBhCiAgICAgICAgIDw8ICIgPSAiIDw8IGIgKiBhIDw8ICIgdW5pdFxuIjsKICAgIGNvdXQgPDwgIisrKysrKysrKysrKysrKysrKysrKysrKytcbiI7CgogICAgcmV0dXJuIDA7Cn0=
#include <iostream>
using namespace std;
int main() {
int a, b, c, d;
// รับค่าให้ถูกต้องตามเงื่อนไข
while (true) {
cout << "Enter number 1: ";
cin >> a;
cout << "Enter number 2: ";
cin >> b;
cout << "Enter number 3: ";
cin >> c;
cout << "Enter number 4: ";
cin >> d;
if (a >= 1 && a <= 100 &&
b >= 1 && b <= 100 &&
c >= 1 && c <= 100 &&
d >= 1 && d <= 100 &&
a == c && b == d) {
break;
}
cout << "Invalid input, please try again.\n\n";
}
cout << "\nInput: " << a << ", " << b << ", " << c << ", " << d << endl;
// เดินเป็นสี่เหลี่ยม
cout << "Start: Walk straight ";
if (a == 1)
cout << "down ";
else
cout << "up ";
cout << a << " unit and turn left." << endl;
cout << "Walk straight for " << b << " units and turn left." << endl;
cout << "Walk straight ";
if (c == 1)
cout << "up ";
else
cout << "down ";
cout << c << " unit and turn left." << endl;
cout << "End: Walk straight for " << d << " units." << endl;
// วาดกรอบ
cout << "+++++++++++++++++++++++++\n";
cout << "Rectangular area = " << b << " * " << a
<< " = " << b * a << " unit\n";
cout << "+++++++++++++++++++++++++\n";
return 0;
}