Created
May 30, 2018 03:14
-
-
Save jason790228/d78b1855737006f181a99a2273830a7b to your computer and use it in GitHub Desktop.
10101
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
void translated(const long long& input, string& output, bool flag = true); | |
void translated(const long long& input, string& output, bool flag) | |
{ | |
int kuti = input % 100; | |
int shata = input % 1000 / 100; | |
int hajar = input % 100000 / 1000; | |
int lakh = input % 10000000 / 100000; | |
if (0 >= input && 0 >= lakh && 0 >= hajar && 0 >= shata && 0 >= kuti) return; | |
if (kuti != 0 && flag == true) output = " " + to_string(kuti) + output; | |
else if (kuti != 0 && flag == false) output = " " + to_string(kuti) + " kuti" + output; | |
else if (kuti == 0 && flag == true) output = output; | |
else if (kuti == 0 && flag == false) output = " kuti" + output; | |
if (shata > 0) output = " " + to_string(shata) + " shata" + output; | |
if (hajar > 0) output = " " + to_string(hajar) + " hajar" + output; | |
if (lakh > 0) output = " " + to_string(lakh) + " lakh" + output; | |
return translated(input / 10000000, output, false); | |
} | |
string add_something(const string& s, const int& c, const long long& input) | |
{ | |
string result = ""; | |
if (c < 10) result = " " + to_string(c); | |
else if (c < 100) result = " " + to_string(c); | |
else if (c < 1000) result = " " + to_string(c); | |
else if (c < 10000) result = to_string(c); | |
return result + "." + s; | |
} | |
int main() | |
{ | |
long long input; | |
string output; | |
int count(1); | |
while (cin >> input) | |
{ | |
if (input == 0) output = " 0"; // GG | |
else translated(input, output); | |
cout << add_something(output, count++, input) << endl; | |
output = ""; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
嘈點太多 先從函式和變數命名開始改善好了...