This is my second article on getting started
background
All kinds of bills and settlement vouchers filled in by banks, units and individuals are important basis for handling payment and settlement and cash receipt and payment, which directly relates to the accuracy, timeliness and safety of payment and settlement. Bills and settlement vouchers are the accounting vouchers for banks, units and individuals to record accounts, and are a kind of written proof for recording economic business and clarifying economic responsibilities. Therefore, to fill in bills and settlement vouchers, we must be standardized and standardized, with complete elements, correct numbers, clear handwriting, no errors, no sloppy, and prevent alteration.
To follow the rules
Fill in Chinese capital amount, features, such as one, two, three, five, land, and pure, eight, nine, ten, hundred, thousand, million, million, yuan, horn, points, zero, and the whole (is), may use 1, 2 (two), three, four, five, six, seven, eight, nine, ten, wool and the other (or zero) to fill in, not the character. If the amount of money is written in traditional Chinese characters, it should also be accepted.
No space shall be left between the number of “RMB”. For important documents with fixed format, the word “RMB” shall be printed in the column of capital amount, and the capital number shall be written immediately after the word “RMB”, and no space shall be left between the “people’s currency” and the number. If the word “RMB” is not printed in the column of capital amount, three words “RMB” should be added.
The usage of the whole (positive) character, the Chinese capital amount number up to “yuan”, after “yuan”, should be “whole” (or “positive”) character; After “Angle”, you can not write “whole” (or “positive”) character; If the capital amount number has “parts”, the word “whole” (or “positive”) is not written after the “parts”.
As for the writing method of zero, when “0” is included in the lowercase amount number of Arabic numerals, the Chinese capitals shall be written in accordance with the Chinese language rules, the composition of amount number and the requirements of preventing alteration. Here are some examples:
- When there is a “0” in the middle of the Arabic numerals, the Chinese capital letter “zero” should be written.
- When there are several consecutive “0” s in the Middle of Arabic numerals, only one “0” can be written in the middle of Chinese capital amount.
- If the Arabic amount number is “0” or there are several consecutive “0” in the middle of the number, the 10,000 bit and the bit are “0”, but the thousand place and corner place are not “0”, only one “0” word may be written in the Chinese capital amount or no “0” word may be written.
- When the corner of the Arabic amount is “0” but the quanta is not “0”, the Chinese capital amount “yuan” should be followed by “zero”.
- The Chinese character “one” in ten or more should not be omitted in Chinese capitals. At ordinary times, oral habits say “tens of thousands”, “tens of thousands” but “ten” represents a number, not a number.
Demonstration code
char* chineseFee( char* dest, char* src )
{
enum
{
START, / * start * /
MINUS, / * minus * /
ZEROINT, / * 0 integer * /
INTEGER, / * * / integers
DECIMAL, /* Decimal point */
DECIMALfRACTION, /* Decimal place */
END, / * * / end
ERROR / * error * /
} status = START;
struct
{
int minus; /*0 is positive, 1 is negative */
int sizeInt;
int sizeDecimal;
int integer[10];
int decimal[10];
} feeInfo;
char* NumberChar[] =
{ "Zero"."One"."贰"."叁"."Boss"."Wu"."Lu"."Pure".""."Nine" };
char* UnitChar[] =
{ "The whole"."Circle"."Pick up"."Hk"."仟"."万"."Pick up"."Hk"."仟"."亿"."Pick up"."Hk"."仟"."$"."Pick up"."Hk"."仟"."YiYi"."Angle"."Points"."Negative"."Renminbi" };
int i, j,size; /* Loop variable */
int zeroTag = 0./ * 0 * /
decZeroTag = 0;
char* pDest = dest;
char* pSrc = src;
int* pInt = feeInfo.integer;
int* pDec = feeInfo.decimal;
/* Initialize */
feeInfo.sizeInt = 0;
feeInfo.sizeDecimal = 0;
feeInfo.minus = 0;
/* Parse the string */
while( 1 )
{
switch ( *pSrc )
{
case The '-' :
status = ( status == START ) ? MINUS : ERROR;
feeInfo.minus = ( status == MINUS ) ? 1 : 0;
break;
case '1' :
case '2' :
case '3' :
case '4' :
case '5' :
case '6' :
case '7' :
case '8' :
case '9' :
case '0' :
if ( *pSrc == '0' && status == ZEROINT )/*|| status == START ) )*/
{
status = ERROR;
break;
}
if ( status == MINUS || status == START || status == INTEGER )
{
if ( *pSrc == '0' && ( status == MINUS || status == START ) )
status = ZEROINT;
else
status = INTEGER;
*pInt = (*pSrc) - 48;
++pInt;
++feeInfo.sizeInt;
}
else if ( status == DECIMAL || status == DECIMALfRACTION )
{
status = DECIMALfRACTION;
*pDec = (*pSrc) - 48;
++pDec;
++feeInfo.sizeDecimal;
}
else
{
status =ERROR;
}
break;
case '. ' :
status = ( status == INTEGER || status == ZEROINT )
? DECIMAL : ERROR;
break;
case '\ 0' :
status = ( status == INTEGER || status == DECIMALfRACTION
|| status == ZEROINT ) ? END : ERROR;
break;
default :
status = ERROR;
}
if ( status == END )
break;
else if ( status == ERROR )
return NULL;
++pSrc;
}
/* When there is only 1 decimal place, set the percentile to 0, so that the following code does not need to distinguish between the two cases */
if ( feeInfo.sizeDecimal == 1 )
{
feeInfo.decimal[ 1 ] = 0;
++feeInfo.sizeDecimal;
}
/* Determine if you need to print the fractional part. If there is a fractional part and the tenths and hundredths are not both 0*/
/* Set zeroTag to 0 if decimal parts need to be printed, otherwise set it to 1*/
if ( feeInfo.sizeDecimal == 0 /* No decimal */| | (! feeInfo.decimal[0 ] && !feeInfo.decimal[ 1]))/* And the decimal part is 0*/
decZeroTag = 1;
else
decZeroTag = 0;
/*printf( "int size: %d decimal size: %d\n", feeInfo.sizeInt, feeInfo.sizeDecimal ); * /
strcpy( pDest, UnitChar[ 21]);/* Initialize the target string - RMB */
if ( feeInfo.minus ) strcat( pDest, UnitChar[ 20]);/ * minus * /
/* Process the integer part */
size = feeInfo.sizeInt;
for( i = 0; i < size; ++i )
{
j = size - i - 1 & 0x3; When j = 0, it is the end of the segment */
if ( feeInfo.integer[ i ] == 0 && j ) /* Processing non-segment tail 0*/
{
zeroTag = 1;
}
else if ( feeInfo.integer[ i ] == 0 && !j ) /* Processing segment end 0*/
{
if ( feeInfo.sizeInt == 1 && decZeroTag ) /* Special processing of the units bit 0*/
strcat( pDest, NumberChar[ feeInfo.integer[ i ] ] );
if( feeInfo.sizeInt ! =1 || decZeroTag )
strcat( pDest, UnitChar[ size - i ] );
zeroTag = 0;
}
else /* Processing non-0 */
{
if ( zeroTag )
{
strcat( pDest, NumberChar[ 0]); zeroTag =0;
}
strcat( pDest, NumberChar[ feeInfo.integer[ i ] ] );
strcat( pDest, UnitChar[ size - i ] );
if ( !j ) zeroTag = 0; /* If it is the end of a segment, set it to unmarked */}}if ( decZeroTag )
{
strcat( pDest, UnitChar[ 0]);/* Print "whole" characters */ without decimal parts
}
else
{
/* Tenths */
if ( feeInfo.decimal[ 0]) {strcat( pDest, NumberChar[ feeInfo.decimal[ 0]]);strcat( pDest, UnitChar[ 18]); }else if( feeInfo.sizeInt ! =1 || feeInfo.integer[ 0]) {strcat( pDest, NumberChar[ feeInfo.decimal[ 0]]); }/* When the percentile is not 0 */
if ( feeInfo.decimal[ 1]) {strcat( pDest, NumberChar[ feeInfo.decimal[ 1]]);strcat( pDest, UnitChar[ 19]); }}return dest;
}
Copy the code
The functionality
Converts the lowercase amount in the source string to uppercase
- Dest destination string
- SRC Lowercase amount the value is a character string
- return
- NULL: Format error in the source string, NULL is returned
- Non-null: The first address of the destination string