如何在函数里表示,大于100的减去50小于100的减去20

来源:百度知道 编辑:UC知道 时间:2024/06/08 19:50:58
具体的方法步骤
还求高手帮忙

vbs:
function fun1(e)
if e>100 then
fun1=e-50
elseif e<100 then
fun1=e-20
else
//这里加上e=100时候的代码
end function

你想用什么软件的函数呢?

if x>100 then x=x-50 else x=x-20

VBS/ASP:
Function Lq_Check_Num(Lq_Check_Num_Val)
If Lq_Check_Num_Val>100 then
Lq_Check_Num=Lq_Check_Num_Val-50
Else
Lq_Check_Num=Lq_Check_Nun_Val-20
End If
End Function

'使用
temp=lq_check_num(你的数据)进行输出

EXCEL:假定数字数据在A1,输出在B1
在B1中输入函数
=IF(A1>100,A1-50,A1-20)

int x;
if(x>100)
x-=50;
else{
if(x<100)
x-20;
}
;======================
int x[n],i;;x[]是你的数组
for(i=0;i<n;i++)
{
if(x[i]>100)
x[i]-=50;
else{
if(x[i]<100)
x[i]-20;
}
}

i>100?i-=50:i+=20
这个简练但没判断i=100时的情况
if(i>100){
i=i-50;
}else if(i<100){
i=i-20;
}
这个就没问题了(这是C或者JAVA的语法)