




已阅读5页,还剩4页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
a, 输入一个年、月、日并计算它是本年度的第几天。b.输入任意一年份,给出该年出生人的属相,如1945年出生的人的属相为“鸡”。c.显示输出20002099年的任何一年的某一月的月历,所要显示的年月有键盘输入。如2002年5月的月历形式如下; 5月 2002年日 一 二 三 四 五 六 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 d.显示输出20002099年的任何一年的年历,并写入一文本文件中。e.以上功能都应从菜单中选择执行。提示:a中若y为年份,d是该年的某月某日从1月1日开始经过的天数,则s=(y-1)*1.2425+d。若s除以7后所得的余数取整后为0,则为周日,为1则周一。program firstquestion implicit none integer:q,i,lday integer:year,month,day,days,mday,ds character(len=2),dimension(1:37):tem! 这个程序可以同时在屏幕和文本中输出计算结果。为了计算不同的问题,引入变量q,当q1时,计算某年月日是此年的第几天;! 当q2时,计算某年的属相;当q3时,计算月历;当q4时,计算年历;当q0时,退出此程序。此外,此程序还设置了对输入! 年、月、日的判断,判断其是否合法。 print *,when q=1,this program can resolve the question that which day some day is in some year! this is the question one. print *,when q=2,this program can obtain the shengxiao of some year! this is the question two. print *,when q=3,this program can obtain the calendar of some month of some year(2000-2099)! this is the question three. print *,when q=4,this program can obtain the Almanac of some year(2000-2099)! this is the question four. print *,If you want to exit from this program,please input q=0. do print *,input the number of q: read *,q if(q=0) exit if (q=1) then2000print *,input the year, the month and the day:read *,year,month,day if (month12.or.month12.or.month2099.or.year2099.or.year12.or.month12.or.month2099.or.year2099.or.year=12.or.m=-12) then n=mod(m,12) else n=m end ifopen(26,file=shengxiao.dat,status=unknown) if (n=0) then print *,The shengxiao of this year is:鸡 write(26,*)The shengxiao of this year is:鸡 else if(n=1.or.n=-11) then print *,The shengxiao of this year is:狗 write(26,*)The shengxiao of this year is:狗 else if(n=2.or.n=-10) then print *,The shengxiao of this year is:猪 write(26,*)The shengxiao of this year is:猪 else if(n=3.or.n=-9) then print *,The shengxiao of this year is:鼠 write(26,*)The shengxiao of this year is:鼠 else if(n=4.or.n=-8) then print *,The shengxiao of this year is:牛 write(26,*)The shengxiao of this year is:牛 else if(n=5.or.n=-7) then print *,The shengxiao of this year is:虎 write(26,*)The shengxiao of this year is:虎 else if(n=6.or.n=-6) then print *,The shengxiao of this year is:兔 write(26,*)The shengxiao of this year is:兔 else if(n=7.or.n=-5) then print *,The shengxiao of this year is:尨 write(26,*)The shengxiao of this year is:尨 else if(n=8.or.n=-4) then print *,The shengxiao of this year is:蛇 write(26,*)The shengxiao of this year is:蛇 else if(n=9.or.n=-3) then print *,The shengxiao of this year is:马 write(26,*)The shengxiao of this year is:马 else if(n=10.or.n=-2) then print *,The shengxiao of this year is:羊 write(26,*)The shengxiao of this year is:羊 else if(n=11.or.n=-1) then print *,The shengxiao of this year is:猴 write(26,*)The shengxiao of this year is:猴 end if close(26)end subroutine shengxiaosubroutine nyli(year,month,mday,ds,tem) implicit none integer:year,month,days,mday integer:i,m,ds,dts,q real:s character(len=2),dimension(1:37):tem call numday(year,month,1,days) call monday(year,month,mday) s=(year-1)*1.2425+days ds=int(s-int(s/7)*7) do i=1,37 tem(i)= end do tem(ds+1)=1;tem(ds+11)=11;tem(ds+12)=12; tem(ds+2)=2;tem(ds+13)=13;tem(ds+14)=14; tem(ds+3)=3;tem(ds+15)=15;tem(ds+16)=16; tem(ds+4)=4;tem(ds+17)=17;tem(ds+18)=18; tem(ds+5)=5;tem(ds+19)=19;tem(ds+20)=20; tem(ds+6)=6;tem(ds+21)=21;tem(ds+22)=22; tem(ds+7)=7;tem(ds+23)=23;tem(ds+24)=24; tem(ds+8)=8;tem(ds+25)=25;tem(ds+26)=26; tem(ds+9)=9;tem(ds+27)=27;tem(ds+28)=28; tem(ds+10)=10;tem(ds+29)=29;tem(ds+30)=30;tem(ds+31)=31; print (26x,i2,月,3x,i4,年),month,year print (18x,7a4),日,一,二,三,四,五,六 print (18x,7a4),(tem(i),i=1,mday+ds) print *end subroutine nylisubroutine numday(year,month,day,days) implicit none integer:year,month,day,days,n logical:leapcall leapyear(year,leap)n=int(month/2) if (month2) then if (leap) then days=days-1 else days=days-2 end if end ifend subroutine numdaysubroutine monday(year,month,mday) implicit none integer:year,month,mday logical:leap call leapyear(year,leap) select case (month) case (4,6,9,11) mday=30 case (1,3,5,7,8,10,12) mday=31 case (2) for_feb:select case (leap) case (.true.) mday=29 case (.false.) mday=28 end select for_feb case default end select end subroutine mondaysubroutine leapyear(year,leap) implicit noneinteger:yearlogical:leapif (mod(year,4)/=0) then leap=.false. else if (mod(year,100)/=0) then leap=.true. else if (mod(year,400)/=0) then leap=.true. else leap=.false.end ifend subroutine leapyearsubroutine leapday(year,month,day,lday) implicit none integer:year,month,day,lday logical:leap call leapyear(year,leap) select case (month) case (4,6,9,11) if (day30.or.day31.or.day29.or.day28.or.day1) then lday=0 else lday=1 end if end select for_feb case default end select end subroutine leapday素数是只能被1与其本身整除的数,下面给出一种寻找素数的方法:a生存一个数组,将其所有的元素初始化为1b 从数组下标为2的元素开始,每次寻找数值为1 的数组元素。当找到时,对其后的元素进行循环,凡是下标值为该元素下标值的整数倍的元素,其值为0。C当这个过程结束时,值为1的元素下标即为所求的素数。program sushu implicit none ! This program is for finding out all the prime ! number which is less than some natural number,! the result display on the screem and the text. integer,dimension(:),allocatable:shuzu integer:i,n print *,input the largest natural number: read *,n allocate(shuzu(1:n) do i=1,n shuzu(i)=1 end do call zhaosushu(shuzu,n) open(28,file=sushu.dat,status=unknown) do
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 银行网点春游活动方案
- 过期妊娠考试题及答案
- 广告手绘考试题及答案
- 骨科职称考试题及答案
- 古典剧目考试题及答案
- 公需考试题及答案
- 工地厨师考试题及答案
- 改良员考试题及答案
- 时间的价值议论文话题5篇
- 防疫保安考试题及答案
- 煤矿安全规程2025版解读
- 尿培养的采集
- 具有法律效应的还款协议书6篇
- 2025年全国企业员工全面质量管理知识竞赛题及参考答案
- 2025年广东省中考英语试卷深度评析及2026年备考策略
- 2025-2026秋中小学升旗仪式演讲稿:(第3周)积跬步养习惯向未来
- 《电气CAD》(汪玲娟)625-5教案 第3课 AutoCAD2020操作界面与绘图环境
- 绿色建筑和绿色建筑材料
- 《七堂保险金信托课》读书笔记思维导图
- Jade6操作和应用优秀课件
- 渐开线花键强度校核(完整计算)
评论
0/150
提交评论