fortran程式碼轉C++
Program Calendar
! 1900,1,1 is Tuesday
implicit none
integer ::counter
integer ::year
integer ::month
integer ::days
integer ::week
integer :: days_in_a_month(12)=(/31,28,31,30,31,30,31,31,30,31,30,31/)
days=2
!1
write (*,*) 'Please input the year'
read (*,*) year
write (*,*) 'Please input the month'
read (*,*) month
!use do to calculate the total days
do counter=1900,year-1
days = days + days_in_a_year(counter)
end do
if ( days_in_a_year(year) == 366 ) days_in_a_month(2)=29 !10
if (month /= 1) then
do counter=1,month-1
days=days+ days_in_a_month(counter)
end do
end if
write(*,*)
week=mod(days,7)
write(*,*) "日 一 二 三 四 五 六"
!20
do counter=1,week
write(*,20) ' '
20 format(A3\)
end do
do counter=1,days_in_a_month(month)
write(*,10) counter
10 format(I3\)
if (mod(counter+week,7) == 0 ) write(*,*)
end do
stop
end program Calendar
! the final output process
integer function days_in_a_year(year)
implicit none
integer :: year
!calculate the number of days in a year
!the input year is variable a
if (year == 1900) then
days_in_a_year =0
if (mod(year,4)=0) then
if (mod(year,100)=0) then
if (mod(year,400)=0) then
days_in_a_year =366
else
days_in_a_year =365
end if
else
days_in_a_year =366
end if
else
days_in_a_year =365
end if
return
end
這是萬用年曆的FORTRAN程式碼
麻煩幫我轉成DEV C++的程式碼
感謝
1 Answer
- 1 decade agoFavorite Answer
程式碼字數有點超過限制
貼不上來
請先連 雜貨店網站 論壇
http://support.dz.forumable.net/tc/adget.php?id=38...
往下找到軟體區
再找 [免費軟體分享] 的這個板塊
文章標題是
萬年曆程式(C++)(給知識+的Josh)