91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 527KB
    文件類型: .7z
    金幣: 1
    下載: 0 次
    發(fā)布日期: 2021-05-10
  • 語言: C/C++
  • 標(biāo)簽:

資源簡介

C語言-遺傳算法的排課源碼,遺傳算法、使用c語言開發(fā),源碼

資源截圖

代碼片段和文件信息

#!/usr/bin/python

#?This?program?is?free?software;?you?can?redistribute?it?and/or
#?modify?it?under?the?terms?of?the?GNU?General?Public?License
#?as?published?by?the?Free?Software?Foundation;?either?version?2
#?of?the?License?or?any?later?version.
#
#?This?program?is?distributed?in?the?hope?that?it?will?be?useful
#?but?WITHOUT?ANY?WARRANTY;?without?even?the?implied?warranty?of
#?MERCHANTABILITY?or?FITNESS?FOR?A?PARTICULAR?PURPOSE.??See?the
#?GNU?General?Public?License?for?more?details.
#Received?from?Vimal?Joseph?on?7?June?2004


import?xml.parsers.expat?sys?

class?Myxml:?
????Parser?=?““?
????timetable={}
????day=““
????hour=““
????hours=[]
????days=[]
????which_tt=““
????#?Prepare?for?parsing?
????def?__init__(self?xml_filename):?
????????assert?xml_filename?!=?““?
????????
????????self.xml_filename?=?xml_filename
????????self.Parser?=?xml.parsers.expat.ParserCreate(??)?
?
????????self.Parser.CharacterDataHandler?=?self.handleCharData?
????????self.Parser.StartElementHandler?=?self.handleStartElement?
????????self.Parser.EndElementHandler?=?self.handleEndElement?
?
????#?Parse?the?xml?file?
????def?parse(self):?
????????try:?
????????????xml_file?=?open(self.xml_filename?“r“)
????????except:?
????????????print?“ERROR:?Can‘t?open?xml?file?%s“%self.xml_filename?
????????????raise?
????????else:?
????????????try:?self.Parser.ParseFile(xml_file)?
????????????finally:?xml_file.close(??)?
?
????#?to?be?overridden?by?implementation-specific?methods?
????def?handleCharData(self?data):?pass
????
????def?handleStartElement(self?name?attrs):
????????if?(name==“Students_Timetable“)?or?(name==“Teachers_Timetable“):
????????????self.which_tt=name
????????????print?“\\documentclass[a4paper12pt]{article}“
????????????print?“\\usepackage{anysize}“
????????????print?“\\marginsize{1in}{1in}{1in}{1in}“
????????????print?“\\begin{document}“
????????????
????????if?(name==“Subgroup“)?and?(self.which_tt==“Students_Timetable“):
????????????self.timetable[“class“]=attrs[‘name‘]
????????????self.days=[]
????????if?(name==“Teacher“)?and?(self.which_tt==“Teachers_Timetable“):
????????????self.timetable[“teacher“]=attrs[‘name‘]
????????????self.days=[]
????????????
????????if?name==“Day“?:
????????????self.day=attrs[‘name‘]
????????????self.days.append(self.day)
????????????self.hours=[]
????????if?name==“Hour“?:
????????????self.hour=attrs[‘name‘]
????????????self.hours.append(self.hour)
????????if?name==“Subject“?:
????????????self.timetable[self.day+self.hour]=attrs[‘name‘]
????????if?name==“Students“?:
????????????self.timetable[self.day+self.hour]=attrs[‘name‘]
????????????
????def?handleEndElement(self?name):
????????if?(name==“Subgroup“)?and?(self.which_tt==“Students_Timetable“):
????????????
????????????print?“\\begin{tabular}{|c|“
????????????for?i?in?self.days:
????????????????print?“c|“?
????????????print?“}“
????????????print?“\\hline“
????????????print?“\\multicolumn{“l(fā)en(self.days)+1“}{|c|}{“?self.timetable[“class“]“}\\\\“
????????????print?

評論

共有 條評論

相關(guān)資源