langs a-z

This commit is contained in:
Ingy döt Net 2013-04-10 22:43:41 -07:00
parent db842d013d
commit d066446780
11389 changed files with 98361 additions and 1020 deletions

View file

@ -0,0 +1,19 @@
let () =
let max = 12 in
let fmax = float_of_int max in
let dgts = int_of_float (ceil (log10 (fmax *. fmax))) in
let fmt = Printf.printf " %*d" dgts in
let fmt2 = Printf.printf "%*s%c" dgts in
fmt2 "" 'x';
for i = 1 to max do fmt i done;
print_string "\n\n";
for j = 1 to max do
fmt j;
for i = 1 to pred j do fmt2 "" ' '; done;
for i = j to max do fmt (i*j); done;
print_newline()
done;
print_newline()

View file

@ -0,0 +1 @@
for(y=1,12,printf("%2Ps| ",y);for(x=1,12,print1(if(y>x,"",x*y)"\t"));print)

View file

@ -0,0 +1,14 @@
/* 12 x 12 multiplication table. */
multiplication_table: procedure options (main);
declare (i, j) fixed decimal (2);
put skip edit ((i do i = 1 to 12)) (X(4), 12 F(4));
put skip edit ( (49)'_') (X(3), A);
do i = 1 to 12;
put skip edit (i, ' |', (i*j do j = i to 12))
(F(2), a, col(i*4+1), 12 F(4));
end;
end multiplication_table;

View file

@ -0,0 +1,14 @@
1 2 3 4 5 6 7 8 9 10 11 12
_________________________________________________
1 | 1 2 3 4 5 6 7 8 9 10 11 12
2 | 4 6 8 10 12 14 16 18 20 22 24
3 | 9 12 15 18 21 24 27 30 33 36
4 | 16 20 24 28 32 36 40 44 48
5 | 25 30 35 40 45 50 55 60
6 | 36 42 48 54 60 66 72
7 | 49 56 63 70 77 84
8 | 64 72 80 88 96
9 | 81 90 99 108
10 | 100 110 120
11 | 121 132
12 | 144

View file

@ -0,0 +1,13 @@
my $max = 12;
my $width = chars $max**2;
my $f = "%{$width}s";
say 'x'.fmt($f), ' ', (1..$max).fmt($f);
say '' x $width, '', '' x $max*$width + $max;
for 1..$max -> $i {
say $i.fmt($f), ' ', (
for 1..$max -> $j {
$i <= $j ?? $i*$j !! '';
}
).fmt($f);
}

View file

@ -0,0 +1,35 @@
Procedure PrintMultiplicationTable(maxx, maxy)
sp = Len(Str(maxx*maxy)) + 1
trenner$ = "+"
For l1 = 1 To maxx + 1
For l2 = 1 To sp
trenner$ + "-"
Next
trenner$ + "+"
Next
header$ = "|" + RSet("x", sp) + "|"
For a = 1 To maxx
header$ + RSet(Str(a), sp)
header$ + "|"
Next
PrintN(trenner$)
PrintN(header$)
PrintN(trenner$)
For y = 1 To maxy
line$ = "|" + RSet(Str(y), sp) + "|"
For x = 1 To maxx
If x >= y
line$ + RSet(Str(x*y), sp)
Else
line$ + Space(sp)
EndIf
line$ + "|"
Next
PrintN(line$)
Next
PrintN(trenner$)
EndProcedure
OpenConsole()
PrintMultiplicationTable(12, 12)
Input()

View file

@ -0,0 +1,35 @@
REBOL [
Title: "12x12 Multiplication Table"
Author: oofoe
Date: 2009-12-26
URL: http://rosettacode.org/wiki/Print_a_Multiplication_Table
]
size: 12
; Because of REBOL's GUI focus, it doesn't really do pictured output,
; so I roll my own. See Formatted_Numeric_Output for more
; comprehensive version:
pad: func [pad n][
n: to-string n
insert/dup n " " (pad - length? n)
n
]
p3: func [v][pad 3 v] ; A shortcut, I hate to type...
--: has [x][repeat x size + 1 [prin "+---"] print "+"] ; Special chars OK.
.row: func [label y /local row x][
row: reduce ["|" label "|"]
repeat x size [append row reduce [either x < y [" "][p3 x * y] "|"]]
print rejoin row
]
-- .row " x " 1 -- repeat y size [.row p3 y y] --
print rejoin [ crlf "What about " size: 5 "?" crlf ]
-- .row " x " 1 -- repeat y size [.row p3 y y] --
print rejoin [ crlf "How about " size: 20 "?" crlf ]
-- .row " x " 1 -- repeat y size [.row p3 y y] --

View file

@ -0,0 +1,24 @@
$ include "seed7_05.s7i";
const proc: main is func
local
const integer: n is 12;
var integer: i is 0;
var integer: j is 0;
begin
for j range 1 to n do
write(j lpad 3 <& " ");
end for;
writeln;
writeln("-" mult 4 * n);
for i range 1 to n do
for j range 1 to n do
if j < i then
write(" ");
else
write(i * j lpad 3 <& " ");
end if;
end for;
writeln("|" <& i lpad 3);
end for;
end func;

View file

@ -0,0 +1,18 @@
$$ MODE TUSCRIPT
x=y="1'2'3'4'5'6'7'8'9'10'11'12"
LOOP n,col=x,cnt=""
skip=n-1
LOOP m,row=y
IF (m==skip) THEN
td=""
ELSE
td=col*row
coleqrow=col*n
IF (td.lt.#coleqrow) td=""
ENDIF
td=CENTER (td,+3," ")
cnt=APPEND (cnt,td," ")
ENDLOOP
col=CENTER (col,+3," ")
PRINT col,cnt
ENDLOOP

View file

@ -0,0 +1,12 @@
#import std
#import nat
table "n" =
~&plrTS(
~&xS pad` @xS <'x ','--'>-- --' | '*hS %nP* nrange/1 "n",
^CthPiC(`-!*h,~&) mat` *xSSK7 pad` *K7ihxPBSS (~&i&& %nP)** nleq&&product**iiK0lK2x nrange/1 "n")
#show+
main = table 12

View file

@ -0,0 +1,14 @@
include c:\cxpl\codes;
int X, Y;
[Format(4, 0);
Text(0, " |"); for X:= 1 to 12 do RlOut(0, float(X));
CrLf(0);
Text(0, " --+"); for X:= 1 to 12 do Text(0, "----");
CrLf(0);
for Y:= 1 to 12 do
[RlOut(0, float(Y)); ChOut(0, ^|);
for X:= 1 to 12 do
if X>=Y then RlOut(0, float(X*Y)) else Text(0, " . .");
CrLf(0);
];
]