你如何在COBOL中创造空格和破折号

Kim*_*235 2 cobol

我的COBOL作业有点麻烦.我必须制作一个程序,写出人的名字和他们的社会安全号码.基本上我有玩具制作像123456789这样的数字显示像123-45-6789和JSDOE这样的名字就像JS DOE一样出现.有人可以帮我吗?

Dr.*_*ius 6

你应该做点什么.

01 toyNumber pic 9(9).

01 yourNumber.
   03 a pic x(3).
   03 b pic x(2).
   03 c pic x(4).

01 outNumber.
   03 a1     pic x(3).
   03 filler pic x    value "-".
   03 b1     pic x(2).
   03 filler pic x    value "-".
   03 c1     pic x(4).      
Run Code Online (Sandbox Code Playgroud)

并在程序中:

   move 123456789 to toyNumber.
   ....
   move toyNumber to yourNumber.
   move a to a1.
   move b to b1.
   move c to c1.

   display outNumber.  
Run Code Online (Sandbox Code Playgroud)

或者,如果您被允许参加作业,您可以使用"移动相应".

希望这有帮助!

PS:这个名字的诀窍是一样的......