这样的PHP计算怎么算的?

WBOY
Release: 2016-06-20 12:42:49
Original
1523 people have browsed it

输入框里输入 1  自动计算得出 150
输入框里输入 2  自动计算得出 300
输入框里输入 3  自动计算得出 450
输入框里输入 4  自动计算得出 600
输入框里输入 5  自动计算得出 750
前面 1 至 5 都是乘以 150;

输入框里输入 6  自动计算得出 894
输入框里输入 7  自动计算得出 1043
输入框里输入 8  自动计算得出 1192
输入框里输入 9  自动计算得出 1192
...
...
输入框里输入 19  自动计算得出 2831
这里 6 至 19 都是乘以 149;

20 至 29 都是乘以 148
30-39  都是乘以 147
40-49  都是乘以 146
50-59  都是乘以 145
60-69  都是乘以 144
以此类推。。。
这种用php怎么计算得到结果呢?


回复讨论(解决方案)

nx150-nxn/10 这个好像有小数点,而且不够倍数。。

function aba($num){	if($num > 0 && $num <= 5){		return $num * 150;	}	if($num >= 6 && $num <= 19){		return $num * 149;	}	if($num >= 20){		return $num * (150 - floor($num/10));	}	return 0;}
Copy after login
Copy after login

function aba($num){	if($num > 0 && $num <= 5){		return $num * 150;	}	if($num >= 6 && $num <= 19){		return $num * 149;	}	if($num >= 20){		return $num * (150 - floor($num/10));	}	return 0;}
Copy after login
Copy after login



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template