a = ′THIS′, f = ′A SAMPLE′, c = ′GOOD′, d = ′NE′, b = ′′, s = CONCAT ( a, CONCAT ( SUBST R( f , 2, 7) , CONCAT ( b , SUBST R( a, 3, 2) ) ) ) t = REP LACA( f, SUBST R( f , 3, 6) , c) , u = CONCAT ( SUBSTR( c, 3, 1) , d) , g = ′IS′, v = CONCAT ( s , CONCAT ( b, CONCAT ( t , CONCAT ( b, u) ) ) ) , 试问∶ s , t , v, LENGTH( s ) , INDEX( v, g) , INDEX( u , g) 各是什么?
时间: 2023-09-11 21:10:56 浏览: 102
根据题目中的赋值语句,可以得到以下变量值:
- a = 'THIS'
- f = 'A SAMPLE'
- c = 'GOOD'
- d = 'NE'
- b = ''
- s = 'THISAMPLE'
- t = 'AAA GOO'
- u = 'ONE'
- g = 'IS'
- v = 'THISAMPLEAAA GOOONE'
其中,s 的计算过程为:
- 将 a 的值 'THIS' 加到空字符串中,得到 'THIS'。
- 将 f 的第 2 到第 7 个字符(即 ' SAMPLE')替换为空字符串,得到 'A'。
- 将空字符串加到上一步的结果中,得到 'A'。
- 将 a 的第 3 到第 2 个字符(即 'IS')替换为空字符串,得到 'THIS'。
- 将上一步的结果与前面的结果拼接,得到 'THISAMPLE'。
t 的计算过程为:
- 将 f 的值 'A SAMPLE' 加到空字符串中,得到 'A SAMPLE'。
- 将 f 的第 3 到第 6 个字符(即 'SAMP')替换为 c 的值 'GOOD',得到 'AAA GOO'。
u 的计算过程为:
- 将 c 的值 'GOOD' 的第 3 个字符(即 'D')加到空字符串中,得到 'D'。
- 将 d 的值 'NE' 加到上一步的结果中,得到 'DONE'。
v 的计算过程为:
- 将 s 的值 'THISAMPLE' 加到空字符串中,得到 'THISAMPLE'。
- 将 b 的值 '' 加到上一步的结果中,得到 'THISAMPLE'。
- 将 t 的值 'AAA GOO' 加到上一步的结果中,得到 'THISAMPLEAAA GOO'。
- 将 b 的值 '' 加到上一步的结果中,得到 'THISAMPLEAAA GOO'。
- 将 u 的值 'DONE' 加到上一步的结果中,得到 'THISAMPLEAAA GOOONE'。
由此可知:
- s 的值为 'THISAMPLE'。
- t 的值为 'AAA GOO'。
- v 的值为 'THISAMPLEAAA GOOONE'。
- s 的长度为 9。
- 字符串 g 在字符串 v 中的索引为 8。
- 字符串 g 在字符串 u 中不存在,因此其索引为 -1。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)