1002 寫出這個數 (20 分)
阿新 • • 發佈:2019-04-16
else return stack ostream ack ber style ring num
#include <iostream> #include <string> #include <stack> using namespace std; int main(){ int sum = 0; string num; stack<int>number; string str[10] = {"ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu"}; cin >> num; for (int i = 0; i < num.size(); i++){ sum += num[i] - ‘0‘; } while (sum != 0){ number.push(sum % 10); sum /= 10; } while (!number.empty()){ cout << str[number.top()]; number.pop(); if (!number.empty()){ cout << ‘ ‘; }else{ cout << endl; } } return 0; }
1002 寫出這個數 (20 分)