Submission
Status:
--------------------
Subtask/Task Score:
0/100
Score: 0
User: chokun
Problemset: Abacus
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-07 13:15:09
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
if (!(cin >> n)) return 0;
// เก็บเลขแต่ละหลักลงอาเรย์ขนาด 8 หลัก (เริ่มจากหลักร้อยล้านไปหลักหน่วย)
vector<int> digits(8, 0);
for (int i = 7; i >= 0; i--) {
digits[i] = n % 10;
n /= 10;
}
// 1. พิมพ์เม็ดบนแถวแรก (ห่างแกน)
for (int j = 0; j < 8; j++) {
cout << (digits[j] < 5 ? "*" : " ") << (j == 7 ? "" : " ");
}
cout << "\n";
// 2. พิมพ์เม็ดบนแถวสอง (ติดแกน)
for (int j = 0; j < 8; j++) {
cout << (digits[j] >= 5 ? "*" : " ") << (j == 7 ? "" : " ");
}
cout << "\n";
// 3. พิมพ์แกนกลางลูกคิด
cout << "-----------------\n";
// 4. พิมพ์เม็ดล่าง 5 แถว (แถวที่ 0 ถึง 4 ของฝั่งด้านล่าง)
for (int row = 0; row < 5; row++) {
for (int j = 0; j < 8; j++) {
int lower_val = digits[j] % 5; // หาจำนวนเม็ดล่างที่ต้องดันขึ้น
// ช่องว่าง ' ' จะอยู่ตรงตำแหน่งที่สัมพันธ์กับค่า lower_val เสมอ
if (lower_val == row) {
cout << " ";
} else {
cout << "*";
}
if (j < 7) cout << " ";
}
cout << "\n";
}
return 0;
}