URI-1037 Solve

Interval

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
You must make a program that read a float-point number and print a message saying in which of following intervals the number belongs: [0,25] (25,50], (50,75], (75,100]. If the read number is less than zero or greather than 100, the program must print the message “Fora de intervalo” that means "Out of Interval".
The symbol '(' represents greather than. For example:
[0,25] indicates numbers between 0 and 25.0000, including both.
(25,50] indicates numbers greather than 25 (25.00001) up to 50.0000000.

Input

The input file contains a floating-point number.

Output

The output must be a message like following example.
Input SampleOutput Sample
25.01Intervalo (25,50]
25.00Intervalo [0,25]
100.00Intervalo (75,100]
-25.02Fora de intervalo

Problem link: https://www.urionlinejudge.com.br/judge/en/problems/view/1037

Solution:

  • [tab]
    • C
      • #include<stdio.h>
        
        int main()
        {
         float n;
         scanf("%f", &n);  //take value from the user
        
         if(n < 0 || n > 100){
          printf("Fora de intervalo\n");
         }else{
          if(n >= 0 && n <= 25){
           printf("Intervalo [0,25]\n");
          }else if(n > 25 && n <= 50){
           printf("Intervalo (25,50]\n");
          }else if(n > 50 && n <= 75){
           printf("Intervalo (50,75]\n");
          }else{
           printf("Intervalo (75,100]\n");
          }
         }
        
         return 0;
        }
    • C++
      • #include<stdio.h>
        
        int main()
        {
         float n;
         scanf("%f", &n);  //take value from the user
        
         if(n < 0 || n > 100){
          printf("Fora de intervalo\n");
         }else{
          if(n >= 0 && n <= 25){
           printf("Intervalo [0,25]\n");
          }else if(n > 25 && n <= 50){
           printf("Intervalo (25,50]\n");
          }else if(n > 50 && n <= 75){
           printf("Intervalo (50,75]\n");
          }else{
           printf("Intervalo (75,100]\n");
          }
         }
        
         return 0;
        }
3/Technology/post-list
Name

Codeforces,53,Problem Solve,90,Programming Tricks,1,URI,37,
ltr
item
DorHubs: URI-1037 Solve
URI-1037 Solve
DorHubs
https://dorhubs.blogspot.com/2019/08/uri-1037-solve.html
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/2019/08/uri-1037-solve.html
true
9087637800571592252
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy