Anonymous
Anonymous asked in 電腦與網際網路程式設計 · 1 decade ago

各位大大們...我想請問有關fortran的事...

請問如果要用fortran打出九九乘法出來...

那程式要怎麼打...

能不能請打出來給我看看...

3Q

2 Answers

Rating
  • 1 decade ago
    Favorite Answer

    program

    implicit none !表示下面所有東西都要自行宣告

    integer i,j,k !宣告整數i,j,k

    k=0

    do i=1,9

    do j=1,9

    write(*,100)j,i,i*j

    100format(I3,"*",I1,"=",i2\)

    k=k+1

    if (k==9) then

    write(*,*)

    k=k-9

    end if

    enddo

    enddo

    end program

    我K是用來每九次換一行的~~~~寫法很多啦

    妳要最笨的寫法的話

    write(*,*)"1*1=1 2*1=2 ~~~~~ 9*1=9"

    write(*,*)"1*2=2 2*2=4 ~~~~~ 9*2=18"

    write(*,*)"1*3=3 2*3=6 ~~~~~ 9*3=27"

    write(*,*)"1*4=4 2*4=8 ~~~~~ 9*4=36"

    write(*,*)"1*5=5 2*5=10 ~~~~~ 9*5=45"

    write(*,*)"1*6=6 2*6=12 ~~~~~ 9*6=54"

    write(*,*)"1*7=7 2*7=14 ~~~~~ 9*7=63"

    write(*,*)"1*8=8 2*8=16 ~~~~~ 9*8=72"

    write(*,*)"1*9=9 2*9=18 ~~~~~ 9*9=81"

    也是跑的出來~~~不過會很累

    2007-12-30 20:17:13 補充:

    有錯誤~~~~我先跑過一次了耶~~~~

    你確定你是

    program

    implicit none !表示下面所有東西都要自行宣告

    integer i,j,k !宣告整數i,j,k

    k=0

    do i=1,9

    do j=1,9

    write(*,100)j,i,i*j

    100format(I3,"*",I1,"=",i2\)

    k=k+1

    if (k==9) then

    write(*,*)

    k=k-9

    end if

    enddo

    enddo

    end program

    全部都用嗎??

    program和 end program妳要自己打出來ㄛ

    Source(s): 我上課學的
    • Login to reply the answers
  • 1 decade ago

    給你看,應該是這樣吧

    PROGRAM TABLE99 '宣告主程式

    DO 50 J=1,9 '1~9

    WRITE(*,10) (I,J,I*J,I=1,9) '輸出

    10 FORMAT(9(I3,'*',I2,'=',I2))

    50 CONTINUE

    END

    • Login to reply the answers
Still have questions? Get your answers by asking now.