AcWing 659. 区间 - Java
原题链接
简单
作者:
KYCygni
,
2021-03-07 12:44:14
,
所有人可见
,
阅读 367
Java 代码
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
double n = cin.nextDouble();
int[] r = {0, 25, 50, 75, 100};
if ( n < r[0] || n > r [4])
System.out.println ("Fora de intervalo");
else
{
for (int i = 0; i < r.length -1; i ++ )
{
if ( n >= r[i] && n <= r[i+1])
{
if (i == 0)
System.out.println ("Intervalo [" + r[i] + "," + r[i+1] + "]");
else
System.out.println ("Intervalo (" + r[i] + "," + r[i+1] + "]");
break;
}
}
}
}
}