请问该怎么将这个自定义函数改写用数组?

将这个自定义函数改写用数组
Function 应纳税(s)
Dim x
x = s - 1600
Select Case x
Case Is < 0: 应纳税 = 0
Case Is < 500: 应纳税 = x * 0.05
Case Is < 2000: 应纳税 = x * 0.1 - 25
Case Is < 5000: 应纳税 = x * 0.15 - 125
Case Is < 20000: 应纳税 = x * 0.2 - 375
Case Is < 40000: 应纳税 = x * 0.25 - 1375
Case Is < 60000: 应纳税 = x * 0.3 - 3375
Case Is < 80000: 应纳税 = x * 0.35 - 6375
Case Is < 100000: 应纳税 = x * 0.4 - 10375
Case Else: 应纳税 = x * 0.45 - 15375
End Select
End Function

莫回无
浏览 172回答 2
2回答

幕布斯7119047

1、因为数组在内存中是一块连续的内存,只要将该数组的首地址传进去,当然就可以访问整个数组了。值得注意的是,由于只传了首地址,函数不知道数组的维数,所以还得把数组的维数传进去,那就可以完全操作该数组了。2、例:有一个函数声明:void fun( int aa[],int size );或者void fun( int *pa,int size );以上两种声明都一样。调用上诉函数时:假设有 int ab[10];fun( ab,10 )就可以了。

慕工程0101907

Function&nbsp;应纳税(s)Dim&nbsp;x,&nbsp;arr,&nbsp;karr&nbsp;=&nbsp;Array(0,&nbsp;0,&nbsp;25,&nbsp;125,&nbsp;375,&nbsp;1375,&nbsp;3375,&nbsp;6375,&nbsp;10375,&nbsp;15375)x&nbsp;=&nbsp;s&nbsp;-&nbsp;1600k&nbsp;=&nbsp;IIf(x&nbsp;<&nbsp;0,&nbsp;0,&nbsp;IIf(x&nbsp;<&nbsp;500,&nbsp;1,&nbsp;IIf(x&nbsp;<&nbsp;2000,&nbsp;2,&nbsp;IIf(x&nbsp;<&nbsp;5000,&nbsp;3,&nbsp;IIf(x&nbsp;<&nbsp;100000,&nbsp;x&nbsp;/&nbsp;20000&nbsp;+&nbsp;4,&nbsp;9)))))应纳税&nbsp;=&nbsp;x&nbsp;*&nbsp;0.05&nbsp;*&nbsp;k&nbsp;-&nbsp;arr(k)End&nbsp;Function
打开App,查看更多内容
随时随地看视频慕课网APP