diff --git a/12/TP-HN-2008/R1/BL1.PAS b/12/TP-HN-2008/R1/BL1.PAS old mode 100755 new mode 100644 diff --git a/12/TP-HN-2008/R1/BL2.PAS b/12/TP-HN-2008/R1/BL2.PAS old mode 100755 new mode 100644 diff --git a/12/TP-HN-2008/R1/BL3.PAS b/12/TP-HN-2008/R1/BL3.PAS old mode 100755 new mode 100644 diff --git a/12/TP-HN-2008/R1/BL4.pas b/12/TP-HN-2008/R1/BL4.pas old mode 100755 new mode 100644 diff --git a/12/TP-HN-2008/R1/CLB.IN b/12/TP-HN-2008/R1/CLB.IN old mode 100755 new mode 100644 diff --git a/12/TP-HN-2008/R1/CLB.OU b/12/TP-HN-2008/R1/CLB.OU old mode 100755 new mode 100644 diff --git a/12/TP-HN-2008/R1/R1.DOC b/12/TP-HN-2008/R1/R1.DOC old mode 100755 new mode 100644 diff --git a/12/TP-HN-2008/R2/tbc.pas b/12/TP-HN-2008/R2/tbc.pas old mode 100755 new mode 100644 diff --git a/12/TP-HN-2009/R1/BTN.PAS b/12/TP-HN-2009/R1/BTN.PAS old mode 100755 new mode 100644 diff --git a/12/TP-HN-2009/R1/HEXA.PAS b/12/TP-HN-2009/R1/HEXA.PAS old mode 100755 new mode 100644 diff --git a/12/TP-HN-2009/R1/PS.PAS b/12/TP-HN-2009/R1/PS.PAS old mode 100755 new mode 100644 diff --git a/12/TP-HN-2009/R2/BAI1.PAS b/12/TP-HN-2009/R2/BAI1.PAS old mode 100755 new mode 100644 diff --git a/12/TP-HN-2009/R2/BAI3.PAS b/12/TP-HN-2009/R2/BAI3.PAS old mode 100755 new mode 100644 diff --git a/12/TP-HN-2010/BAI1.PAS b/12/TP-HN-2010/BAI1.PAS old mode 100755 new mode 100644 diff --git a/12/TP-HN-2010/BAI2.PAS b/12/TP-HN-2010/BAI2.PAS old mode 100755 new mode 100644 diff --git a/12/TP-HN-2010/BAI3 b/12/TP-HN-2010/BAI3 old mode 100755 new mode 100644 diff --git a/12/TP-HN-2010/BAI3.INP b/12/TP-HN-2010/BAI3.INP old mode 100755 new mode 100644 diff --git a/12/TP-HN-2010/BAI3.OUT b/12/TP-HN-2010/BAI3.OUT old mode 100755 new mode 100644 diff --git a/12/TP-HN-2010/BAI3.o b/12/TP-HN-2010/BAI3.o old mode 100755 new mode 100644 diff --git a/12/TP-HN-2010/BAI3.pas b/12/TP-HN-2010/BAI3.pas old mode 100755 new mode 100644 diff --git a/12/TP-HN-2010/TP-2010.png b/12/TP-HN-2010/TP-2010.png old mode 100755 new mode 100644 diff --git a/12/TP-ThanhHoá-2009/bai4.py b/12/TP-ThanhHoá-2009/bai4.py old mode 100755 new mode 100644 diff --git a/12/TP-ThanhHoá-2009/bai4pas_srcgen.py b/12/TP-ThanhHoá-2009/bai4pas_srcgen.py old mode 100755 new mode 100644 diff --git a/NTU/hamar.py b/NTU/hamar.py old mode 100755 new mode 100644 diff --git a/NTU/sagain_geninp.py b/NTU/sagain_geninp.py old mode 100755 new mode 100644 diff --git a/THT/B/QG-2014/DIC.DAT b/THT/B/QG-2014/DIC.DAT old mode 100755 new mode 100644 diff --git a/THT/B/QG-2014/sample.pas b/THT/B/QG-2014/sample.pas old mode 100755 new mode 100644 diff --git a/THT/B/QG-2016/remainder.py b/THT/B/QG-2016/remainder.py old mode 100755 new mode 100644 diff --git a/THT/B/QG-2016/trigrid.py b/THT/B/QG-2016/trigrid.py old mode 100755 new mode 100644 diff --git a/THT/C/Q-2016/bai2.py b/THT/C/Q-2016/bai2.py old mode 100755 new mode 100644 diff --git a/THT/C/Q-2016/bai3.py b/THT/C/Q-2016/bai3.py old mode 100755 new mode 100644 diff --git a/THT/C/QG-2017/ImgViewer.exe b/THT/C/QG-2017/ImgViewer.exe old mode 100644 new mode 100755 diff --git a/THT/C/QG-2017/xxiii.py b/THT/C/QG-2017/xxiii.py old mode 100755 new mode 100644 diff --git a/others/other/README.md b/others/other/README.md index 0d4198b..d593fb3 100644 --- a/others/other/README.md +++ b/others/other/README.md @@ -979,3 +979,13 @@ lớn nhất. | VDD.INP | VDD.OUT | | ---------------------------------------------------------------------- | :-----: | | 5 1 5
0 0 0 1 1
0 0 0 0 1
1 1 0 0 1
1 1 0 0 0
0 1 0 0 0 | 2 | + +## Số chữ số chính phương + +Viết chương trình in ra số lượng số chính phương có `n` chữ số. + +### Ví dụ + +| stdin | stdout | +| :---: | :----: | +| 2 | 6 | diff --git a/thinkperl6/draft.p6 b/thinkperl6/draft.p6 index 7f74238..a8add76 100755 --- a/thinkperl6/draft.p6 +++ b/thinkperl6/draft.p6 @@ -84,3 +84,48 @@ sub estimate-pi { 1 / $factor / Srinivasa-Ramanujan } #put abs estimate-pi() - pi; + +sub ducks { map * ~ 'ack' , flat('J'..'N', 'Ou', 'P', 'Qu') } +#put ducks; + +sub count(Str $string, Str $substr, Int $index = 0, Int $result = 0) { + my $i = index $string, $substr, $index; + return $result if $i === Any; + count $string, $substr, $i + 1, $result + 1 +} +#put count 'banana', 'na'; + +sub bubble-sort(@seq is copy) { + my $done; + repeat { + $done = True; + for ^(@seq.elems - 1) -> $i { + if @seq[$i] > @seq[$i+1] { + (@seq[$i], @seq[$i+1]) = @seq[$i+1], @seq[$i]; + $done = False + } + } + } until $done; + @seq +} +#put bubble-sort <4 2 6 5 3 9 1>; + +sub select-sort(@seq is copy) { + for ^(@seq.elems - 1) -> $i { + for $i..^@seq.elems -> $j { + (@seq[$i], @seq[$j]) = @seq[$j], @seq[$i] if @seq[$i] > @seq[$j] + } + } + @seq +} +#put select-sort <4 2 6 5 3 9 1>; + +sub insert-sort(@seq is copy) { + for 1..^@seq.elems -> $i { + loop (my $j = $i; $j and @seq[$j] < @seq[$j - 1]; $j--) { + (@seq[$j], @seq[$j - 1]) = @seq[$j - 1], @seq[$j] + } + } + @seq +} +#put insert-sort <4 2 6 5 3 9 1>;