- $KCODE='SJIS'
- a=[]
- ha={}
- File.open("103.txt").each_line{ |l|
- a.push(l.strip.chomp.to_i)#number
- }
- a.sort!
- af=File.open("103.txt","w")
- af.puts(a)
- af.close()
- b=[]
- File.open("102.txt").each_line{|l|
- b.push(l.strip.chomp.to_i)#number
- }
- b.sort!
- bf=File.open("102.txt","w")
- bf.puts(b)
- bf.close()
- cc=File.open("same.txt","w")
- cc.puts(a & b)
- dd=File.open("diff.txt","w")
- dd.puts( b.size()>a.size()?(b-a):(a-b))#compare from - compare to
- =begin
- 102.txt
- -------
- 10
- 5
- 8
- 103.txt
- -------
- 30
- 5
- 20
- 8
- diff.txt
- -------
- 20
- 30
- =end
compare items by array
最新推荐文章于 2024-02-21 23:33:59 发布