-2

I have a variable x with values from 1 to 390. I need to group it in intervals of 5, in other words if x<6 then interval=1; if x>5 and X<11then interval=2; if x>10 and x<16 then interval=3; etc.

What is a shorter way of writing this code without having to repeat this if statement all the way to x=390?

4

1 に答える 1

0

これは本当に少し基本的すぎますが、大丈夫です。

interval = ceil(x/5);
于 2013-08-25T14:05:10.300 に答える