-1
這是我的簡單代碼。 我想用打分的名字打開文件。 例如,如果a是4,那麼b是5 a要打開名稱爲9或result9.txt的文件。 可以這樣做嗎?以分數名稱打開文件
Program Dilema
Implicit none
Integer::a,b,c
Write(*,'(5x,"Choose the first number: ")')
Read(*,'(i2)')a
Write(*,'(5x,"Choose the second number: ")')
Read(*,'(i2)')b
c=a+b
Open(10,File=C,Status='Unknown')
write(10,*) c
Close(10)
Stop
End program Dilema
感謝了很多。 它正在工作。 請問,你能告訴我如何打開,例如: Score_C.txt –
有點乾淨的方式,'寫(文件名,'(a,I0,a)')'結果',c''。txt'' 。 ('I0'確保沒有空格) – agentp
@Judge_Dred,write(filename,'(a,I0,a)')'Score _',c,'.txt',因爲agentp建議,我們不需要連接,所以我編輯答案 – innoSPG