Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - C language programming: input an integer, and then read and output it according to Chinese habits. For example, 1052 is pronounced as 1052.
C language programming: input an integer, and then read and output it according to Chinese habits. For example, 1052 is pronounced as 1052.
# Contains? & ltstdio.h & gt

# Contains? & ltstring.h & gt

const? Charles? *? sCommonCnNumbers? =? "0 1234567890 tsumoru negative";

//? Study within 10 thousand.

Charles? *? I2cnSub 1(char? *? o,? Not signed? int? num,? int? ys? =? 0)

{

If (num? & gt? 9999)? Return? NULL

Not signed? int? q? =? num? /? 1000;

num? -=? q? *? 1000;

Not signed? int? b? =? num? /? 100;

num? -=? b? *? 100;

Not signed? int? s? =? num? /? 10;

Not signed? int? g? =? num? -? s? *? 10;

int? l? =? 0;

if(q)? {*o++? =? q? +? '0'; ? *o++? =? q’; ? ys? =? 1; }

Or what? If (ys? ==? 1)? l? =? 1;

If (b)

{

If (l? ==? 1)? {*o++? =? '0'; ? l? =? 0; ? ys? =? 0; }

*o++? =? b? +? '0'; ? *o++? =? b’; ? ys? =? 1;

}

Or what? If (ys? ==? 1)? l? =? 1;

If (s)

{

If (l? ==? 1)? {*o++? =? '0'; ? l? =? 0; ? ys? =? 0; }

If (s? ==? 1? & amp& amp? ys? ==? 0)? ;

Or what? *o++? =? s? +? '0'; ?

*o++? =? s’; ? ys? =? 1;

}

Or what? If (ys? ==? 1)? l? =? 1;

If (g)

{

If (l? ==? 1)? {*o++? =? '0'; }

*o++? =? g? +? '0';

}

*o? =? 0;

Return? o;

}

//? The number string is converted into a chinese numerals string.

Charles? *? I2cnSub2(char? *? o,? const? Charles? *? Me? const? Charles? *? kCN)

{

Charles? *? Or? =? o;

size_t? Ryan. =? Strlen (1);

Charles? *? buf? =? New? char[len],? *pbl,? * pbh

Memcpy(buf, me,? len);

pbl? =? buf

pbh? =? pbl? +? len

And (pbl? & lt? pbh)

{

Switch (*pbl++)

{

Case? '0':? memcpy(o,? kCN,? 2); ? o+= 2; ? Break;

Case? ' 1':? memcpy(o,? kCN? +? 2,? 2); ? o+= 2; ? Break;

Case? '2':? memcpy(o,? kCN? +? 4,? 2); ? o+= 2; ? Break;

Case? '3':? memcpy(o,? kCN? +? 6,? 2); ? o+= 2; ? Break;

Case? '4':? memcpy(o,? kCN? +? 8,? 2); ? o+= 2; ? Break;

Case? '5':? memcpy(o,? kCN? +? 10,? 2); ? o+= 2; ? Break;

Case? '6':? memcpy(o,? kCN? +? 12,? 2); ? o+= 2; ? Break;

Case? '7':? memcpy(o,? kCN? +? 14,? 2); ? o+= 2; ? Break;

Case? '8':? memcpy(o,? kCN? +? 16,? 2); ? o+= 2; ? Break;

Case? '9':? memcpy(o,? kCN? +? 18,? 2); ? o+= 2; ? Break;

Case? s ':memcpy(o,? kCN? +? 20,? 2); ? o+= 2; ? Break;

Case? b ':memcpy(o,? kCN? +? 22,? 2); ? o+= 2; ? Break;

Case? Q': memcpy(o,? kCN? +? 24,? 2); ? o+= 2; ? Break;

Case? w ':memcpy(o,? kCN? +? 26,? 2); ? o+= 2; ? Break;

Case? y ':memcpy(o,? kCN? +? 28,? 2); ? o+= 2; ? Break;

Case? '-':? memcpy(o,? kCN? +? 30,? 2); ? o+= 2; ? Break;

Default value:

;

}

}

*o? =? 0;

Delete? []? buf

Return? Or;

};

//? Convert the numbers into chinese numerals, and the result conforms to chinese numerals's reading method.

Charles? *? I2cn(char? *? o,? __int64? num,? const? Charles? *? kCN? =? sCommonCnNumbers)

{

Charles? *? Or? =? o;

const? Not signed? __int64? kMaxInt32? =? 4294967296ui64

const? Not signed? __int64? kYY=? 100000000000000 ui64;

const? Not signed? __int64? kWY=? 10000000000 ui64;

const? Not signed? __int64? kY=? 10000000 ui 64;

const? Not signed? __int64? kW=? 10000 ui 64;

If (num? & lt? 0)? {*o++? =? '-'; ? num? =? -num; }?

int? ys? =? 0,? l? =? 0;

If (num? & gt? kYY)

{

Not signed? int? yy? =? (unsigned? int)(num? /? kYY);

num? -=? yy? *? kYY

o? =? I2cnSub 1(o,? YY);

*o++? =? y’;

If (num? & lt? kY)? *o++? =? y’;

ys? =? 1;

}

Or what? If (ys? ==? 1)? l? =? 1;

If (num? & gt? kWY)

{

If (l? ==? 1)? {*o++? =? '0'; ? l? =? 0; ? ys? =? 0; }

Not signed? int? wy? =? (unsigned? int)(num? /? kWY);

num? -=? wy? *? kWY

o? =? I2cnSub 1(o,? Hello? ys);

*o++? =? w’;

If (num? & lt? kY)? *o++? =? y’;

ys? =? 1;

}

Or what? If (ys? ==? 1)? l? =? 1;

If (num? & gt? kY)

{

If (l? ==? 1)? {*o++? =? '0'; ? l? =? 0; ? ys? =? 0; }

Not signed? int? y? =? (unsigned? int)(num? /? kY);

num? -=? y? *? kY;

o? =? I2cnSub 1(o,? y,? ys);

*o++? =? y’;

ys? =? 1;

}

Or what? If (ys? ==? 1)? l? =? 1;

If (num? & gt? Kilowatt)

{

If (l? ==? 1)? {*o++? =? '0'; ? l? =? 0; ? ys? =? 0; }

Not signed? int? W? =? (unsigned? int)(num? /? kW);

num? -=? W? *? Kilowatt;

o? =? I2cnSub 1(o,? w,? ys);

*o++? =? w’;

}

If (number)

{

If (l? ==? 1)? {*o++? =? '0'; ? ys? =? 0; }

o? =? I2cnSub 1(o,? (unsigned? int)num,? ys);

}

*o? =? 0;

Return? I2cnSub2 (or, or,? kCN);

}

int? Master ()

{

__int64? x;

Charles? buf[ 128];

Printf ("Please enter a number:");

scanf("%I64d ",& ampx);

Printf ("The Chinese pronunciation of this number is: %s\n", I2cn(buf,? x));

Return? 0;

}