forked from tejaswankalluri/make-pull-request
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path7thOct.cpp
More file actions
39 lines (36 loc) · 846 Bytes
/
Copy path7thOct.cpp
File metadata and controls
39 lines (36 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<iostream>
using namespace std;
const string A[] = { "", "1", "2", "3", "4", "5",
"6", "7", "8", "9" };
string digit(unsigned long long int n, string left)
{
if (n == 0) {
return "0";
}
return A[n / 10] + A[n % 10] + left;
}
string notowords(unsigned long long int n)
{
string res;
res = digit((n % 10), "");
if (n > 100 && n % 100) {
res = "and " + res;
}
if(n>=10)
res = digit(((n / 10) % 10), " ten ") + res;
if(n>=100)
res = digit(((n / 100) % 10), " Hundred ") + res;
if(n>=1000)
res = digit(((n / 1000) % 100), " Thousand ") + res;
if(n>=100000)
res = digit(((n / 100000) % 100), " Lac, ") + res;
if(n>=10000000)
res = digit((n / 10000000) % 100, " Crore, ") + res;
return res;
}
int main()
{
unsigned long long n;
cin>>n;
cout<<notowords(n);
}