--> Interval (beeCrowd- 1037) URI 1037 Solution C, Python | Alpha Codist

Search This Blog

Interval (beeCrowd- 1037) URI 1037 Solution C, Python

Interval beeCrowd 1037 URI Solution C Python programming coding solution solved explained formula loop easy what judge auto test bee Neilor Tonin braz

Interval

Interval beeCrowd 1037 URI Solution C Python programming coding solution solved explained formula loop easy what judge auto test bee Neilor Tonin braz

The formula is:

  1. Take input. 
  2. Create a list of numbers that are given as intervals. The list will have one number once.
  3. Loop through the list.
  4. If the index is at 100 then it means it is out of range. Print "Fora de intervalo"
  5. If your input is zero or greater than your current index(loop value ex: i)," and it is less than the next index(ex:i+1). Print "Intervalo -->([<--i,i+1]" note that if the number is at the first interval you will have to print "(". For other intervals you will have to print "[".

N.B: "[" means include the first number. Whereas "(" means do not include the first number.

The solution in C:


#include <stdio.h>

int main() {
 
    double x;
    scanf("%lf",&x);
    int listed[6] = {0,25,50,75,100,10000};
    int i=0;
    while(i<=4){
        if(i==4){
            printf("Fora de intervalo\n");
            break;
        }
        if((x==0 || listed[i]<x) && x<=listed[i+1]){
            if(i==0){
                printf("Intervalo [%d,%d]\n",listed[i],listed[i+1]);
                break;
            } else{
                printf("Intervalo (%d,%d]\n",listed[i],listed[i+1]);
                break;
            }
        }
        i++;
    }
 
    return 0;
}


The solution in Python:


x = float(input())
listed = [0,25,50,75,100,10000]
i=0;

while i<=4:
    if i==4:
        print("Fora de intervalo")
        break
    if (x==0 or listed[i]<x) and x<=listed[i+1]:
        if i==0:
            print("Intervalo [%d,%d]" % (listed[i],listed[i+1]))
            break
        else:
            print("Intervalo (%d,%d]" % (listed[i],listed[i+1]))
            break
    i+=1

COMMENTS

Name

beeCrowd,11,C,10,Computer,9,Downloads,3,HTML,1,My Creation,2,Python,24,Python-Soft,1,Shooting,2,
ltr
item
Alpha Codist: Interval (beeCrowd- 1037) URI 1037 Solution C, Python
Interval (beeCrowd- 1037) URI 1037 Solution C, Python
Interval beeCrowd 1037 URI Solution C Python programming coding solution solved explained formula loop easy what judge auto test bee Neilor Tonin braz
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4UtfZH6Q1eyPkmkSGy5o_vglG9T2vIHWp2hbHshlilgm-nk93dNCRBXncllI5BkEOhAVfxIYkNK52Nd1o47FzMIY-4yQBvecRz3bdO9KF5wBl01MfhrfZSkhtkKj2bVQ8NGqh8afGUtpUj8q1xCPpISFg67vgbByF2ZZlZxD1HJQjSG-s751_p9tCPQ/w640-h422/1037.png
https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4UtfZH6Q1eyPkmkSGy5o_vglG9T2vIHWp2hbHshlilgm-nk93dNCRBXncllI5BkEOhAVfxIYkNK52Nd1o47FzMIY-4yQBvecRz3bdO9KF5wBl01MfhrfZSkhtkKj2bVQ8NGqh8afGUtpUj8q1xCPpISFg67vgbByF2ZZlZxD1HJQjSG-s751_p9tCPQ/s72-w640-c-h422/1037.png
Alpha Codist
https://alphacodist.blogspot.com/2022/12/interval1034.html
https://alphacodist.blogspot.com/
https://alphacodist.blogspot.com/
https://alphacodist.blogspot.com/2022/12/interval1034.html
true
7547834254111195316
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 Table of Content