# sprintf.pl
# “а—e : sprintf‚МѓTѓ“ѓvѓ‹ѓvѓЌѓOѓ‰ѓЂ
# Copyright (c) 2011 Mitsuo Minagawa, All rights reserved.
# (minagawa@fb3.so-net.ne.jp)  
# Ћg—p•ы–@ : c:\>perl sprintf.pl
#   
open(OUT1,">output.txt");

$z	=	"abcdefg";
$m	=	109;
print OUT1 "109‚М%c= ".sprintf("%c\n", $m);
print OUT1 "z‚М’l‚Н= ".sprintf("%s\n", $z);
print OUT1 "%10s   = ".sprintf("%10s\n", $z);
print OUT1 "%5s    = ".sprintf("%5s\n", $z);
print OUT1 "%5.s   = ".sprintf("%5.s\n", $z);
print OUT1 "%.2s   = ".sprintf("%.2s\n", $z);
print OUT1 "%-10s  = ".sprintf("%-10s\n", $z);

$a	=	1234.5678;
$b	=	123456.789;
$x	=	1234567.89;
$c	=	-1234.5678;
$d	=	-123456.789;
$y	=	-1234567.89;
$xx	=	1234567890.45;
$yy	=	-1234567890.45;

print OUT1 "%10s‚М’l‚Н%d = ".sprintf("%10s‚М’l‚Н%d\n", $z,$a);
$temp	=	"%10s‚М’l‚Н%d\n" % [$z,$a];
print OUT1 "%10s‚М’l‚Н%d = ".$temp;
print OUT1 "\n";
print OUT1 "a‚М’l‚Н= ".sprintf("%s\n", $a);
print OUT1 "%d     = ".sprintf("%d\n", $a);
print OUT1 "%+d    = ".sprintf("%+d\n", $a);
print OUT1 "%10d   = ".sprintf("%10d\n", $a);
print OUT1 "%10.2d = ".sprintf("%10.2d\n", $a);
print OUT1 "%-d    = ".sprintf("%-d\n", $a);
print OUT1 "%-10d  = ".sprintf("%-10d\n", $a);
print OUT1 "%f     = ".sprintf("%f\n", $a);
print OUT1 "%b     = ".sprintf("%b\n", $a);
print OUT1 "%o     = ".sprintf("%o\n", $a);
print OUT1 "%x     = ".sprintf("%x\n", $a);
print OUT1 "%X     = ".sprintf("%X\n", $a);
print OUT1 "%e     = ".sprintf("%e\n", $a);
print OUT1 "%11e   = ".sprintf("%11e\n", $a);
print OUT1 "%.3e   = ".sprintf("%.3e\n", $a);
print OUT1 "%7.2e  = ".sprintf("%7.2e\n", $a);
print OUT1 "%07.2e = ".sprintf("%07.2e\n", $a);
print OUT1 "%f     = ".sprintf("%f\n", $a);
print OUT1 "%11f   = ".sprintf("%11f\n", $a);
print OUT1 "%.3f   = ".sprintf("%.3f\n", $a);
print OUT1 "%7.2f  = ".sprintf("%7.2f\n", $a);
print OUT1 "%07.2f = ".sprintf("%07.2f\n", $a);
print OUT1 "%g     = ".sprintf("%g\n", $a);
print OUT1 "%G     = ".sprintf("%G\n", $a);
print OUT1 "%2d    = ".sprintf("%2d\n", $a);
print OUT1 "%02d   = ".sprintf("%02d\n", $a);
print OUT1 "%8d    = ".sprintf("%8d\n", $a);
print OUT1 "%08d   = ".sprintf("%08d\n", $a);
print OUT1 "%.2f   = ".sprintf("%.2f\n", $a);
print OUT1 "%2.2f  = ".sprintf("%2.2f\n", $a);
print OUT1 "%8f    = ".sprintf("%8f\n", $a);
print OUT1 "%8.8f  = ".sprintf("%8.8f\n", $a);
print OUT1 "%08f   = ".sprintf("%08f\n", $a);
print OUT1 "%08.f  = ".sprintf("%08.f\n", $a);
print OUT1 "%08.2f = ".sprintf("%08.2f\n", $a);
print OUT1 "%8.3f% = ".sprintf("%8.3f%\n", $a);
print OUT1 "%#b    = ".sprintf("%#b\n", $a);
print OUT1 "%#o    = ".sprintf("%#o\n", $a);
print OUT1 "%#x    = ".sprintf("%#x\n", $a);
print OUT1 "%#X    = ".sprintf("%#X\n", $a);
print OUT1 "\n";
print OUT1 "b‚М’l‚Н= ".sprintf("%s\n", $b);
print OUT1 "b‚М%e  = ".sprintf("%e\n", $b);
print OUT1 "b‚М%f  = ".sprintf("%f\n", $b);
print OUT1 "b‚М%g  = ".sprintf("%g\n", $b);
print OUT1 "b‚М%G  = ".sprintf("%G\n", $b);
print OUT1 "\n";
print OUT1 "x‚М’l‚Н= ".sprintf("%s\n", $x);
print OUT1 "x‚М%e  = ".sprintf("%e\n", $x);
print OUT1 "x‚М%f  = ".sprintf("%f\n", $x);
print OUT1 "x‚М%g  = ".sprintf("%g\n", $x);
print OUT1 "x‚М%G  = ".sprintf("%G\n", $x);
print OUT1 "\n";
print OUT1 "xx‚М’l‚Н=".sprintf("%s\n", $xx);
print OUT1 "%ld    = ".sprintf("%ld\n", $xx);
print OUT1 "%11ld  = ".sprintf("%11ld\n", $xx);
print OUT1 "%.3ld  = ".sprintf("%.3ld\n", $xx);
print OUT1 "%7.2ld = ".sprintf("%7.2ld\n", $xx);
print OUT1 "%07.2ld= ".sprintf("%07.2ld\n", $xx);
print OUT1 "%d     = ".sprintf("%d\n", $xx);
print OUT1 "%11d   = ".sprintf("%11d\n", $xx);
print OUT1 "%.3d   = ".sprintf("%.3d\n", $xx);
print OUT1 "%7.2d  = ".sprintf("%7.2d\n", $xx);
print OUT1 "%07.2d = ".sprintf("%07.2d\n", $xx);
print OUT1 "%lu    = ".sprintf("%lu\n", $xx);
print OUT1 "%11lu  = ".sprintf("%11lu\n", $xx);
print OUT1 "%.3lu  = ".sprintf("%.3lu\n", $xx);
print OUT1 "%7.2lu = ".sprintf("%7.2lu\n", $xx);
print OUT1 "%07.2lu= ".sprintf("%07.2lu\n", $xx);
print OUT1 "%u     = ".sprintf("%u\n", $xx);
print OUT1 "%11u   = ".sprintf("%11u\n", $xx);
print OUT1 "%.3u   = ".sprintf("%.3u\n", $xx);
print OUT1 "%7.2u  = ".sprintf("%7.2u\n", $xx);
print OUT1 "%07.2u = ".sprintf("%07.2u\n", $xx);
print OUT1 "%lo    = ".sprintf("%lo\n", $xx);
print OUT1 "%11lo  = ".sprintf("%11lo\n", $xx);
print OUT1 "%.3lo  = ".sprintf("%.3lo\n", $xx);
print OUT1 "%7.2lo = ".sprintf("%7.2lo\n", $xx);
print OUT1 "%07.2lo= ".sprintf("%07.2lo\n", $xx);
print OUT1 "%o     = ".sprintf("%o\n", $xx);
print OUT1 "%11o   = ".sprintf("%11o\n", $xx);
print OUT1 "%.3o   = ".sprintf("%.3o\n", $xx);
print OUT1 "%7.2o  = ".sprintf("%7.2o\n", $xx);
print OUT1 "%07.2o = ".sprintf("%07.2o\n", $xx);
print OUT1 "%lx    = ".sprintf("%lx\n", $xx);
print OUT1 "%11lx  = ".sprintf("%11lx\n", $xx);
print OUT1 "%.3lx  = ".sprintf("%.3lx\n", $xx);
print OUT1 "%7.2lx = ".sprintf("%7.2lx\n", $xx);
print OUT1 "%07.2lx= ".sprintf("%07.2lx\n", $xx);
print OUT1 "%x     = ".sprintf("%x\n", $xx);
print OUT1 "%11x   = ".sprintf("%11x\n", $xx);
print OUT1 "%.3x   = ".sprintf("%.3x\n", $xx);
print OUT1 "%7.2x  = ".sprintf("%7.2x\n", $xx);
print OUT1 "%07.2x = ".sprintf("%07.2x\n", $xx);

print OUT1 "\n";
print OUT1 "c‚М’l‚Н= ".sprintf("%s\n", $c);
print OUT1 "%d     = ".sprintf("%d\n", $c);
print OUT1 "%+d    = ".sprintf("%+d\n", $c);
print OUT1 "%10d   = ".sprintf("%10d\n", $c);
print OUT1 "%10.2d = ".sprintf("%10.2d\n", $c);
print OUT1 "%-d    = ".sprintf("%-d\n", $c);
print OUT1 "%-10d  = ".sprintf("%-10d\n", $c);
print OUT1 "%f     = ".sprintf("%f\n", $c);
print OUT1 "%b     = ".sprintf("%b\n", $c);
print OUT1 "%o     = ".sprintf("%o\n", $c);
print OUT1 "%x     = ".sprintf("%x\n", $c);
print OUT1 "%X     = ".sprintf("%X\n", $c);
print OUT1 "%e     = ".sprintf("%e\n", $c);
print OUT1 "%11e   = ".sprintf("%11e\n", $c);
print OUT1 "%.3e   = ".sprintf("%.3e\n", $c);
print OUT1 "%7.2e  = ".sprintf("%7.2e\n", $c);
print OUT1 "%07.2e = ".sprintf("%07.2e\n", $c);
print OUT1 "%f     = ".sprintf("%f\n", $c);
print OUT1 "%11f   = ".sprintf("%11f\n", $c);
print OUT1 "%.3f   = ".sprintf("%.3f\n", $c);
print OUT1 "%7.2f  = ".sprintf("%7.2f\n", $c);
print OUT1 "%07.2f = ".sprintf("%07.2f\n", $c);
print OUT1 "%2d    = ".sprintf("%2d\n", $c);
print OUT1 "%02d   = ".sprintf("%02d\n", $c);
print OUT1 "%8d    = ".sprintf("%8d\n", $c);
print OUT1 "%08d   = ".sprintf("%08d\n", $c);
print OUT1 "%.2f   = ".sprintf("%.2f\n", $c);
print OUT1 "%2.2f  = ".sprintf("%2.2f\n", $c);
print OUT1 "%8f    = ".sprintf("%8f\n", $c);
print OUT1 "%8.8f  = ".sprintf("%8.8f\n", $c);
print OUT1 "%08f   = ".sprintf("%08f\n", $c);
print OUT1 "%08.f  = ".sprintf("%08.f\n", $c);
print OUT1 "%08.2f = ".sprintf("%08.2f\n", $c);
print OUT1 "%8.3f% = ".sprintf("%8.3f%\n", $c);
print OUT1 "%#b    = ".sprintf("%#b\n", $c);
print OUT1 "%#o    = ".sprintf("%#o\n", $c);
print OUT1 "%#x    = ".sprintf("%#x\n", $c);
print OUT1 "%#X    = ".sprintf("%#X\n", $c);
print OUT1 "\n";
print OUT1 "d‚М’l‚Н= ".sprintf("%s\n", $d);
print OUT1 "d‚М%e  = ".sprintf("%e\n", $d);
print OUT1 "d‚М%f  = ".sprintf("%f\n", $d);
print OUT1 "d‚М%g  = ".sprintf("%g\n", $d);
print OUT1 "d‚М%G  = ".sprintf("%G\n", $d);
print OUT1 "\n";
print OUT1 "y‚М’l‚Н= ".sprintf("%s\n", $y);
print OUT1 "y‚М%e  = ".sprintf("%e\n", $y);
print OUT1 "y‚М%f  = ".sprintf("%f\n", $y);
print OUT1 "y‚М%g  = ".sprintf("%g\n", $y);
print OUT1 "y‚М%G  = ".sprintf("%G\n", $y);
print OUT1 "\n";
print OUT1 "yy‚М’l‚Н=".sprintf("%s\n", $yy);
print OUT1 "%ld    = ".sprintf("%ld\n", $yy);
print OUT1 "%11ld  = ".sprintf("%11ld\n", $yy);
print OUT1 "%.3ld  = ".sprintf("%.3ld\n", $yy);
print OUT1 "%7.2ld = ".sprintf("%7.2ld\n", $yy);
print OUT1 "%07.2ld= ".sprintf("%07.2ld\n", $yy);
print OUT1 "%d    = ".sprintf("%d\n", $yy);
print OUT1 "%11d  = ".sprintf("%11d\n", $yy);
print OUT1 "%.3d  = ".sprintf("%.3d\n", $yy);
print OUT1 "%7.2d = ".sprintf("%7.2d\n", $yy);
print OUT1 "%07.2d= ".sprintf("%07.2d\n", $yy);
print OUT1 "%lu    = ".sprintf("%lu\n", $yy);
print OUT1 "%11lu  = ".sprintf("%11lu\n", $yy);
print OUT1 "%.3lu  = ".sprintf("%.3lu\n", $yy);
print OUT1 "%7.2lu = ".sprintf("%7.2lu\n", $yy);
print OUT1 "%07.2lu= ".sprintf("%07.2lu\n", $yy);
print OUT1 "%u     = ".sprintf("%u\n", $yy);
print OUT1 "%11u   = ".sprintf("%11u\n", $yy);
print OUT1 "%.3u   = ".sprintf("%.3u\n", $yy);
print OUT1 "%7.2u  = ".sprintf("%7.2u\n", $yy);
print OUT1 "%07.2u = ".sprintf("%07.2u\n", $yy);
print OUT1 "%lo    = ".sprintf("%lo\n", $yy);
print OUT1 "%11lo  = ".sprintf("%11lo\n", $yy);
print OUT1 "%.3lo  = ".sprintf("%.3lo\n", $yy);
print OUT1 "%7.2lo = ".sprintf("%7.2lo\n", $yy);
print OUT1 "%07.2lo= ".sprintf("%07.2lo\n", $yy);
print OUT1 "%o     = ".sprintf("%o\n", $yy);
print OUT1 "%11o   = ".sprintf("%11o\n", $yy);
print OUT1 "%.3o   = ".sprintf("%.3o\n", $yy);
print OUT1 "%7.2o  = ".sprintf("%7.2o\n", $yy);
print OUT1 "%07.2o = ".sprintf("%07.2o\n", $yy);
print OUT1 "%lx    = ".sprintf("%lx\n", $yy);
print OUT1 "%11lx  = ".sprintf("%11lx\n", $yy);
print OUT1 "%.3lx  = ".sprintf("%.3lx\n", $yy);
print OUT1 "%7.2lx = ".sprintf("%7.2lx\n", $yy);
print OUT1 "%07.2lx= ".sprintf("%07.2lx\n", $yy);
print OUT1 "%x     = ".sprintf("%x\n", $yy);
print OUT1 "%11x   = ".sprintf("%11x\n", $yy);
print OUT1 "%.3x   = ".sprintf("%.3x\n", $yy);
print OUT1 "%7.2x  = ".sprintf("%7.2x\n", $yy);
print OUT1 "%07.2 x= ".sprintf("%07.2x\n", $yy);

close(OUT1);
