24小时热门版块排行榜    

CyRhmU.jpeg
查看: 1594  |  回复: 10
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

superstat54

木虫 (小有名气)

[求助] Fortran 怎么把字符串转换为表达式

比如从文件中读入这样一串字符 "100 + x*x"复制给a,"sin(x)"赋值给b,如果程序中x=0.5,怎么在程序中把这一串字符"a + b"转换为表达式100 + x*x + sin(x) ,并求出其值?
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

马永涛的虫

新虫 (小有名气)


jjdg: 金币+1, 感谢参与 2012-03-21 01:43:49
引用回帖:
7楼: Originally posted by 马永涛的虫 at 2012-03-20 14:27:28:
可以直接读啊:
        read(2,999)line
        write(20,999)line
        enddo
999   format(a)
       然后赋值就行了
      a=100 + x*x
      b=sin(x)
再给X赋值,求a+b

line 是读那一行,就是你要的字符型变量在的那一行。a和b的类型是实型,但要你在前面声明。
10楼2012-03-20 21:09:09
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 11 个回答

lurencyj

木虫 (著名写手)

【答案】应助回帖


感谢参与,应助指数 +1
jjdg: 金币+1, 感谢参与 2012-03-21 01:43:17
可以用use语句试试。。。
很女子很弓虽大
2楼2012-03-19 21:34:52
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

superstat54

木虫 (小有名气)

引用回帖:
2楼: Originally posted by lurencyj at 2012-03-19 21:34:52:
可以用use语句试试。。。

能否写的详细些?谢谢!
3楼2012-03-19 21:38:46
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

lurencyj

木虫 (著名写手)

【答案】应助回帖


jjdg: 金币+1, 感谢参与 2012-03-21 01:43:23
The USE statement has the syntax

       USE environment-name,filename
where filename is optional, and is a character-valued expression. It causes the text of the named environment to be, in effect, placed in the program at the point where the USE statement was encountered, and the programs whose object code is in the environment to be callable from the program in which the USE statement is found, as well as (less usefully) from any other programs loaded into memory at the same time.

In some implementations, because ENVIRONMENTs are incompatible with the available linkage loading mechanisms, the filename may be compulsory the first time a USE statement referring to environments in a given file is encountered, but not in subroutines, even externally compiled subroutines, later in the source stream.
很女子很弓虽大
4楼2012-03-19 21:41:09
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见