从一个变量到剩余的变量求和 [英] Sum from one variable to the rest left

查看:77
本文介绍了从一个变量到剩余的变量求和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含100个变量的代码,我认为我必须使它们成为数组,即使我一直遇到问题。我还在学习。

变量是

variable1,variable2,variabl3等等。

因此,根据用户提交的内容,让我们说3.给出从变量4到100的总数。



非常感谢你的时间和帮助!



我的尝试:



我尝试制作变量并制作无限的ifs,但必须有更好的方法。

I have a code with 100 variables, which I'm thinking I must have made them arrays, even though I keep having problems with it. I'm still learning.
variables are
variable1, variable2, variabl3, and so on.
So depending on what the user submits, ,let's say 3. Gives the total from variable 4 to 100.

Thanks a lot for your time and help!

What I have tried:

I have tried making variables and making infinite "ifs" but there's gotta be a better way.

推荐答案


a =数组(1,2,3,4, 5 ... 98, 99,100);
a = array(1, 2, 3, 4, 5 ... 98, 99, 100);


b = array_slice(
b = array_slice(


这篇关于从一个变量到剩余的变量求和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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