Home > Back-end >  The C language
The C language

Time:06-03

Write a function that will be a floating point number said ten thousand yuan the following amount into RMB capital form

CodePudding user response:

Define a string array length of 10, keep all uppercase characters respectively into an array of
Const char num [10] [3]={" zero \ 0 ", "one \ 0", "two \ 0",,,,,,,}
Put money into an array of length is 6, representing one thousand, one hundred, 10, bits, Angle, a
With this array of numerical index uppercase characters of the string inside, just together
1234.56
Into an array of six is 1 2 3 4 5 6
Corresponding to the uppercase characters above ErBai SAN she transgressed, wu jiao lu fen
Try to write yourself, take code to ask

CodePudding user response:

Fun
reference 1 floor response:
define a string array length of 10, keep all uppercase characters respectively into an array of
Const char num [10] [3]={" zero \ 0 ", "one \ 0", "two \ 0",,,,,,,}
Put money into an array of length is 6, representing one thousand, one hundred, 10, bits, Angle, a
With this array of numerical index uppercase characters of the string inside, just together
1234.56
Into an array of six is 1 2 3 4 5 6
Corresponding to the uppercase characters above ErBai SAN she transgressed, wu jiao lu fen
Try to write yourself, get the code to ask

There is a problem, thousand hundred come from?

CodePudding user response:

Ten thousand yuan the following, put into each bit is used to index array, the output of hundreds of directly into the printf function to use
Hundred thousand printf (" % s % s % s to pick up,,,,, ")

May need to bother to want to consider 1001.00 this output is one thousand and one yuan, or allow output one thousand usd and dedicated one yuan zero Angle of zero

CodePudding user response:

 const char num [10] [3]={" zero \ 0 ", "one \ 0", "two \ 0",,,,,,,} 

This is wrong
"" take a \ 0
Assuming that Chinese characters 2 bytes
This can take up to 4 bytes
Only 3 bytes array element
C + + is a syntax error
C language can


Fun
reference 1 floor response:
define a string array length of 10, keep all uppercase characters respectively into an array of
Const char num [10] [3]={" zero \ 0 ", "one \ 0", "two \ 0",,,,,,,}
Put money into an array of length is 6, representing one thousand, one hundred, 10, bits, Angle, a
With this array of numerical index uppercase characters of the string inside, just together
1234.56
Into an array of six is 1 2 3 4 5 6
Corresponding to the uppercase characters above ErBai SAN she transgressed, wu jiao lu fen
Try to write yourself, get the code to ask

CodePudding user response:

Fun
reference 3 floor response:
ten thousand yuan the following, put into each bit is used to index array, the output of hundreds of directly into the printf function to use
Hundred thousand printf (" % s % s % s to pick up,,,,, ")

May need to bother to want to consider 1001.00 this output is one thousand and one yuan, or allow output one thousand usd and dedicated one yuan zero Angle of zero

#include Void main () {char a [9]={' 1 ', '2', '3', 'boss', 'wu', 'land' and 'pure', ' ', 'nine'}; Double num. int temp; The scanf (" % f ", & amp; Num); Printf (" please enter a number "); Temp=num/1000; If (temp!=0) {printf (" % c $", a [] temp - 1); } num=num - (num/1000) * 1000; Temp=num/100; If (temp!=0) {printf (" % c arm, "a [] temp - 1); } num=num - (num/100) * 100; Temp=num/10; If (temp!=0) {printf (" % c pick up, "a [] temp - 1); } num=num - (num/10 * 10; Temp=num/1; If (temp!=0) {printf (" % c yuan, "a [] temp - 1); } num=num - (num/1) * 1; Temp=num/0.1; If (temp!=0) {printf (" % c Angle, "a [] temp - 1); } num=num - (num/0.1) * 0.1; Temp=num/0.01; If (temp!=0) {printf (" % c ", a [] temp - 1); }}

CodePudding user response:

reference 5 floor weixin_45812742 reply:
Quote: refer to the third floor fun response:
ten thousand yuan the following, put into each bit is used to index array, the output of hundreds of directly into the printf function to use
Hundred thousand printf (" % s % s % s to pick up,,,,, ")

May need to bother to want to consider 1001.00 this output is one thousand and one yuan, or allow output one thousand usd and dedicated one yuan zero Angle of zero

#include Void main () {char a [9]={' 1 ', '2', '3', 'boss', 'wu', 'land' and 'pure', ' ', 'nine'}; Double num. int temp; The scanf (" % f ", & amp; Num); Printf (" please enter a number "); Temp=num/1000; If (temp!=0) {printf (" % c $", a [] temp - 1); } num=num - (num/1000) * 1000; Temp=num/100; If (temp!=0) {printf (" % c arm, "a [] temp - 1); } num=num - (num/100) * 100; Temp=num/10; If (temp!=0) {printf (" % c pick up, "a [] temp - 1); } num=num - (num/10 * 10; Temp=num/1; If (temp!=0) {printf (" % c yuan, "a [] temp - 1); } num=num - (num/1) * 1; Temp=num/0.1; If (temp!=0) {printf (" % c Angle, "a [] temp - 1); } num=num - (num/0.1) * 0.1; Temp=num/0.01; If (temp!=0) {printf (" % c ", a [] temp - 1); }}

Can have a look at what I was wrong, behind is not successful

CodePudding user response:

Inside an array to zero, the number 10

CodePudding user response:

Also can't put the Chinese characters as a character to deal with, as a string

CodePudding user response:

references to make fun of the eighth floor response:
cannot put Chinese characters as a character to deal with, as a string to

Oh, I see, thank you

CodePudding user response:

Can you send code to me, I want to learn

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related