URI Online Judge Solution | 1037 Interval

Here is a link

http://www.mathsisfun.com/sets/intervals.html

Check there about the interval notation section…

Interval Notation

In “Interval Notation” we just write the beginning and ending numbers of the interval, and use:

  • [ ] a square bracket when we want to include the end value, or
  • ( ) a round bracket when we don’t

Like this:

Interval Notation

Example: (5, 12]

Means from 5 to 12, do not include 5, but do include 12

#include<iostream>
#include<cstdio>
#include<cmath>
int main()
{
    double i;
scanf("%lf",&i);
if(i>0 && i<25)
    {
    printf("Intervalo (0,25]\n");
    }
    else if(i>25 && i<50){
        printf("Intervalo (25,50]\n");
    }
    else if(i>50 && i<75){
        printf("Intervalo (50,75]\n");
    }
     else if(i>75 && i<100){
        printf("Intervalo (75,100]\n");
    }
else{
    printf("Fora de intervalo\n");
}
return 0;
}

Wrong answer 20% code:

#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;
int main(){
double num;
cin>>num;

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

return 0;
}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *