659. Interval

659. Interval

Given a floating point number, please determine which range the number belongs to: [0,25], (25,50], (50,75], (75,100).

If the given value is less than 0 or greater than 100, the program will output "Fora de intervalo", indicating that it is out of range.

Open interval (a, b): All real numbers between the real number a and the real number b, but not including a and b.

Closed interval [a, b]: All real numbers between the real number a and the real number b, including a and b.

Input format

Enter a floating point number.

Output format

Determine which interval the input value lies in, and output according to the format "Intervalo x", where x is one of the interval ranges [0,25], (25,50], (50,75], (75,100).

If the value is outside all intervals, "Fora de intervalo" is output.

Input sample:

25.01

Sample output:

Intervalo (25,50]
#include <cstdio>

int main()
{
	double n;
	scanf("%lf", &n);
	if (0 <= n && n <=25) printf("Intervalo [0,25]\n");
	else if (25 < n && n <=50) printf("Intervalo (25,50]\n");
	else if (50 < n && n <=75) printf("Intervalo (50,75]\n");
	else if (75 < n && n <=100) printf("Intervalo (75,100]\n");
	else printf("Fora de intervalo\n");
	
	
	
	
	
	return 0;
}

Guess you like

Origin blog.csdn.net/qq_42465670/article/details/114751031