在单个语句中对多个变量进行相同的值分配 [英] Same value assignment of multiple variables in a single statement

查看:105
本文介绍了在单个语句中对多个变量进行相同的值分配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以为不同的变量分配相同的值而无需在单个语句中构造数组?

Is there a way where I can assign the same value for different variables without constructing an array in a single statement?

例如,如果我有变量 a,b,c,d e ,我可以分配类似的东西

For example, if I have variables a,b,c,d, and e, can I assign something like

a=b=c=d=e=10.0 

?

我知道我可以单行执行:

I know that I can do in a single line:

a=10.0; b=10.0; c=10.0; d=10.0; e=10.0

但这不是我想要的,因为如果以后我想将值10.0更改为其他值,则必须在各处进行更改.

But that is not I want since if I want to change the value 10.0 later to something else, I have to make the change everywhere.

推荐答案

加入Fortranners,您知道您想要...

Come on Fortranners, you know you want to ...

equivalence(a,b,c,d,e)

现在所有这些流氓都将始终具有相同的值.

Now all those rascals are going to have the same value at all times.

这篇关于在单个语句中对多个变量进行相同的值分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆