-
Notifications
You must be signed in to change notification settings - Fork 1
/
QtC++.cpp
72 lines (64 loc) · 2.38 KB
/
QtC++.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <stdint.h>
#include <QString>
enum {SAND,FIRST,FIRSTPERFIX,SECOND,SECONDPERFIX,HUNDRED,BIG,BIGPERFIX};
const char* const numbers[][10] = {
{" و"},
{"واحد","إثنان","ثلاثة","أربعة","خمسه","سته","سبعه","ثمانيه","تسعه","عشرة"},
{"واحد","اثنا","ثلاث","أربع","خمس","ست","سبع","ثمان","تسع"},
{"عشر","عشرين","ثلاثين","أربعين","خمسين","ستين","سبعين","ثمانين","تسعين"},
{" عشر","عشرون","ثلاثون","أربعون","خمسون","ستون","سبعون","ثمانون","تسعون"},
{"مائة","مئتا"},
{""," الف"," مليون"," مليار"},
{""," آلاف"," ملايين"," ملايير"}
};
QString numberToLetter(const unsigned int number)
{
QString sFinal;
for(int i=3;i>=0;i--){
int16_t nPrice;
if(i == 3)
nPrice = number / 1000000000;
else if(i == 2)
nPrice = (number - number / 1000000000 * 1000000000) / 1000000;
else if(i == 1)
nPrice = (number - number / 1000000 * 1000000) / 1000;
else
nPrice = (number - number / 1000 * 1000);
if(nPrice <= 0)
continue;
if(nPrice >= 100){
const int8_t temp = nPrice / 100;
if(!sFinal.isEmpty())
sFinal += numbers[SAND][SAND];
if(temp > 2){
sFinal += numbers[FIRSTPERFIX][temp-1];
sFinal += + numbers[HUNDRED][0];
}
else
sFinal += numbers[HUNDRED][temp - 1];
}
const int8_t temp = nPrice / 10;
if(nPrice % 10 > 0){
if(!sFinal.isEmpty())
sFinal += numbers[SAND][SAND];
if(temp % 10 > 0)
sFinal += numbers[FIRSTPERFIX][(nPrice % 10) - 1];
else
sFinal += numbers[FIRST][(nPrice % 10) - 1];
}
if(temp % 10 > 0){
if(!sFinal.isEmpty()){
if(temp % 10 > 1)
sFinal += numbers[SAND][SAND];
sFinal += numbers[SECONDPERFIX][(temp % 10) - 1];
}
else
sFinal += numbers[SECOND][(temp % 10) - 1];
}
if(nPrice > 10)
sFinal += numbers[BIG][i];
else
sFinal += numbers[BIGPERFIX][i];
}
return sFinal;
}