範例程式碼 uva10101

//uva10101
#include <iostream>
#include <string>
using namespace std;
string table[] = {"", "shata", "hajar", "lakh", "kuti"};

int main() {
	int i = 1;
	long long int n;
	while((cin >> n)){
		string s = "";
		int t = 1, temp = 0;

		if(n == 0)
			s = "0";
		else{
			temp = n % 100;
			if(temp != 0)
				s.insert(0, to_string(temp));
			n = n /100;
		}
		while(n>0){
			if(t % 4 == 1){
				temp = n % 10;
				n /= 10;
			}
			else{
				temp = n % 100;
				n /= 100;
			}
			if(temp != 0){
				if(s.compare("") != 0)
					s.insert(0, to_string(temp) + " " + table[t] + " ");
				else
					s.insert(0, to_string(temp) + " " + table[t]);
			}
			else if(temp == 0 && t % 4 == 0){
				if(s.compare("") != 0)
					s.insert(0, table[t] + " ");
				else
					s.insert(0, table[t]);
			}
			t = (t % 4) + 1;
		}
		if(i < 10)
			cout << "   ";
		else if(i < 100)
			cout << "  ";
		else if(i < 1000)
			cout << " ";
		cout << i++ << ". " << s << endl;
	}
	return 0;
}