2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,3 +1,6 @@
;Task:
Express a number in decimal as a fixed-length string with leading zeros.
For example, the number 7.125 could be expressed as "00007.125".
For example, the number   '''7.125'''   could be expressed as   '''00007.125'''.
<br><br>

View file

@ -0,0 +1,10 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. NUMERIC-OUTPUT-PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-EXAMPLE.
05 X PIC 9(5)V9(3).
PROCEDURE DIVISION.
MOVE 7.125 TO X.
DISPLAY X UPON CONSOLE.
STOP RUN.

View file

@ -0,0 +1,16 @@
printf("%f", Pi);
3.141593
printf("%.0f", Pi);
3
printf("%.2f", Pi);
3.14
printf("%08.2f", Pi);
00003.14
printf("%8.2f", Pi);
3.14
printf("%-8.2f|", Pi);
3.14 |
printf("%+08.2f", Pi);
+0003.14
printf("%+0*.*f",8, 2, Pi);
+0003.14

View file

@ -0,0 +1,8 @@
fn main() {
let x = 7.125;
println!("{:9}", x);
println!("{:09}", x);
println!("{:9}", -x);
println!("{:09}", -x);
}

View file

@ -0,0 +1,11 @@
10 LET n=7.125
20 LET width=9
30 GO SUB 1000
40 PRINT AT 10,10;n$
50 STOP
1000 REM Formatted fixed-length
1010 LET n$=STR$ n
1020 FOR i=1 TO width-LEN n$
1030 LET n$="0"+n$
1040 NEXT i
1050 RETURN