问题描述
在大多数编程语言中,您可以在输出过程中将字符串与变量混合和匹配.但是,我似乎找不到找到这种方法的好方法.这是我的代码:
In most programming languages, you can mix and match strings with variables during output. However, I can't seem to find a good way to do so. Here is my code:
Prompt A,B
√(A^2+B^2)->C
If iPart(C)≠C
Then
Disp "C = √(",C
Else
Disp "C = ",C
End
Goto ED
Label ED
不幸的是,使用此代码,它最终像这样打印:
Unfortunately, with this code, it ends up printing like so:
A? 3
B? 5
C = √(
34
Done
这不是我想要的.我希望能够将其打印为C = √(34)
,但目前找不到任何混合变量和字符串的方法.任何帮助将不胜感激.
This is not what I want. I would love to be able to have it print C = √(34)
, but I currently can't find any way to mix variables and strings. Any help would be appreciated.
推荐答案
在ti-83的ti-basic中,加号(+)用于连接字符串.像这样:
In ti-basic for the ti-83 the plus (+) is used to concatenate strings. Like this:
Disp "foo"+" "+"bar"
将输出:
"foo bar"
您必须记住使用string()
将数字转换为字符串:
You must remember to convert numbers to strings using string()
though:
Disp "C=√("+string(c)+")"
将输出:
"C=√(34)"
Disp "C=√("+c+")"
(没有string()
)会引发错误.
Disp "C=√("+c+")"
(no string()
) will throw an error.
这篇关于在同一行上显示变量和字符串(TI-Basic)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!