| |

VerySource

 Forgot password?
 Register
Search
View: 773|Reply: 5

Excuse me: How does the variable qianwei in the currency conversion program play a judgment role?

[Copy link]

2

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

Post time: 2020-1-25 21:20:01
| Show all posts |Read mode
I would like to ask: How does the variable qianwei in the following program play a role in judging? According to my level, I have never understood it. Sorry, ask you! Thank you!

function Tform1.SmallTOBig (small: real): string;
  var SmallMonth, BigMonth: string;
  wei1, qianwei1: string [2];
  wei, qianwei, dianweizhi, qian: integer;
  begin
    qianwei: =-2;
    Smallmonth: = formatfloat ('0.00', small);
    dianweizhi: = pos ('.', Smallmonth); {position of decimal point}
    for qian: = length (Smallmonth) downto 1 do
  begin
  {Continue if you read something other than a decimal point}
  if qian <> dianweizhi then
  begin
  {Numbers in position are converted to uppercase}
  case strtoint (copy (Smallmonth, qian, 1)) of
  1: wei1: = 'One'; 2: wei1: = '贰';
  3: wei1: = 'Three'; 4: wei1: = 'Three';
  5: wei1: = '吴'; 6: wei1: = '陆';
  7: wei1: = '柒'; 8: wei1: = '捌';
  9: wei1: = '玖'; 0: wei1: = 'zero';
  end;
  {Judge the uppercase position, you can continue to increase to the maximum of the real type}
  case qianwei of
  -3: qianwei1: = 'cent';
  -2: qianwei1: = 'minute';
  -1: qianwei1: = 'Angle';
  0: qianwei1: = 'yuan';
  1: qianwei1: = 'pick up';
  2: qianwei1: = '百';
  3: qianwei1: = 'Thousands';
  4: qianwei1: = '10,000';
  5: qianwei1: = 'pick up';
  6: qianwei1: = '百';
  7: qianwei1: = 'Thousands';
  8: qianwei1: = 'billion';
  9: qianwei1: = 'ten';
  10: qianwei1: = '百';
  11: qianwei1: = 'Thousands';
  end;
  inc (qianwei);
  BigMonth: = wei1 + qianwei1 + BigMonth; {Combined into capitals}
  end;
  end;
  SmallTOBig: = BigMonth;
  end;
Reply

Use magic Report

0

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-2-16 11:45:01
| Show all posts
qianwei: =-2;
Smallmonth: = formatfloat ('0.00', small);
These two are initializations, and inc (qianwei) is the change.
The value range of qianwei is [-2..11].
Reply

Use magic Report

2

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-3-19 13:00:01
| Show all posts
I was asking how it (qianwei) is related to the position of the input lowercase variable (small), that is, how to get the position of the value of small? From the beginning to the end, I did not see that qianwei has a relationship with small Connected statements. Consult, thank you!
Reply

Use magic Report

0

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-3-22 12:30:01
| Show all posts
strtoint (copy (Smallmonth, qian, 1)) should be wrong here strtoint (copy (Smallmonth, qianwei, 1))
Reply

Use magic Report

2

Threads

7

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 China

 Author| Post time: 2020-4-11 22:15:01
| Show all posts
Isn't it wrong? This function works correctly.
Reply

Use magic Report

0

Threads

6

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-4-29 17:45:01
| Show all posts
It's because I didn't take a closer look, it's true that qian is in the loop, I didn't see it at first. qianwei changes with qian, and qian is the position of the specific number
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list