Created
March 24, 2019 04:24
-
-
Save maehrm/bc91a9b5e7ba9181e11cfd06f28b4408 to your computer and use it in GitHub Desktop.
平成20年度春期試験_基本情報午後問6(Ruby)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def markup_reference in_filename, out_filename | |
ref_name_tbl = [] | |
File.open(in_filename, "r") do |ifp| | |
File.open(out_filename, "w") do |ofp| | |
str = ifp.read | |
str.scan(/(.*?)\\(.+?)\\/) {|pre, ref_name| | |
ofp.print pre | |
if i = ref_name_tbl.index(ref_name) | |
ofp.print "[#{i + 1}]" | |
else | |
ref_name_tbl << ref_name | |
ofp.print "[#{ref_name_tbl.size}]" | |
end | |
} | |
ofp.print $' | |
ofp.print "\n\nReferences\n" | |
ref_name_tbl.each_with_index {|e, i| | |
ofp.print "[#{i + 1}] #{e}\n" | |
} | |
end | |
end | |
end | |
if $0 == __FILE__ | |
if ARGV.size != 2 | |
puts "Usage: #{__FILE__} infile outfile" | |
abort | |
end | |
markup_reference ARGV[0], ARGV[1] | |
end |
上記の文書に対して、以下の文献リストが表示します。
The program language includes C, COBOL, Java, etc[1]. The feature of the Java language has been to have taken the idea of object-oriented[2]. In other languages, the idea of object-oriented is being taken[1].
References
[1] Computer Journal
[2] Java Report
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The program language includes C, COBOL, Java, etc\Computer Journal\. The feature of the Java language has been to have taken the idea of object-oriented\Java Report\. In other languages, the idea of object-oriented is being taken\Computer Journal\.