想找一个函数,它的功能是这样的:

来源:百度知道 编辑:UC知道 时间:2024/06/03 09:37:26
如有一个值,设为A
如果0<A<20,则扣二分
如果20<=A<50,则扣一分
如果50<=A<70,则加一分
如果70<=A<100,则加二分

请问用什么子函数??
谢谢
就是难得写
所以想看有简单的没有?

vb:
public function getScore(a as Integer) as Integer
dim score as integer
if a>0 and a<20 then score=-2
if a>=20 and a<50 then score=-1
if a>=50 and a<70 then score=1
if a>=70 and a<100 then score=1
getScore=score
end sub

C/C++
public:
int getScore(int a){
int score;
if (a>0 and a<20) score=-2
if (a>=20 and a<50) score=-1
if (a>=50 and a<70) score=1
if (a>=70 and a<100) score=1
return score;
}

C#/JAVA
public int getScore(int a){
int score;
if (a>0 and a<20) score=-2
if (a>=20 and a<50) score=-1
if (a>=50 and a<70) score=1
if (a>=70 and a<100) score=1
return score;
}

自己编这么个函数不就完了

14.请编写一个函数int fun(int x),它的功能是: 编写函数computNum( int num),它的功能是计算任意输入的一个正整数的各位数字之和,结果由函数返回。 Excel函数如何实现这样的功能?! 2.编写函数fun,它的功能是:计算并输出下列级数和: 请教一个asp函数的功能 编写一个函数 fun ,他的功能是找出一组整形数据中的最大值和它所在的下标,通过行参返回最大值和下标。 编写一个函数fun,它的功能是:删除字符串中的数字字符。例如:输入的字符串为:123abc67de89f输出为abcde 当一个函数具有什么性质时能保证它的导函数是连续的? 一个函数在区间上可导是否它的导函数是连续的,请举出反例 编写一个函数该函数的功能是判断一个整数是不是素数,在主函数中调用该函数,输出200以内的所有的素数