URI 1037 Solve

Solve of URI 1037 (Interval) in C & C++

How to solve:
1. In this problem, we have to place a number into an interval;

2. Input contains a floating point number.
3. If inputted number is between 0 to 25, print "Intervalo [0,25]".
4. If inputted number is between 25to 50, print "Intervalo [25,50]".
5. If inputted number is between 50 to 75, print "Intervalo [50,75]".
6. If inputted number is between 75 to 100, print "Intervalo [75,100]".
7. Otherwise print "Fora de intervalo" (That means Out of Interval). 

See sample input and output for better understanding with printing output.
Go through problem description and see my solution for clear concept. Thanks. :)



Solution in C:
//URI online judge 1037 solution in C
//This solution is made by Mehedi Hasan Kajol


#include<stdio.h>
int main(void){
    float input;
    scanf(" %f ", &input);


    if( input >= 0 && input <= 25)
        printf("Intervalo [0,25]\n");
    else if( input > 25 && input <= 50)
        printf("Intervalo (25,50]\n");
    else if( input >50 &&input <=75 )
        printf("Intervalo (50,75]\n");
    else if( input> 75 && input<=100 )
        printf("Intervalo (75,100]\n");
    else
        printf("Fora de intervalo\n");
    return 0;
}



Solution in C++:

//URI online judge 1037 solution in C++
//This solution is made by Mehedi Hasan Kajol


#include<iostream>

using namespace std;
int main(void){
    float input;
    cin >> input;


    if( input >= 0 && input <= 25)

        cout << "Intervalo [0,25]" << endl;
    else if( input > 25 && input <= 50)
        cout << "Intervalo (25,50]" << endl;
    else if( input >50 &&input <=75 )
        cout << "Intervalo (50,75]" << endl;
    else if( input> 75 && input<=100 )
        cout << "Intervalo (75,100]" << endl;
    else
         cout << "Fora de intervalo" << endl;
    return 0;
}



Post a Comment

Previous Post Next Post