URI-1041 Solve

Coordinates of a Point

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Write an algorithm that reads two floating values (x and y), which should represent the coordinates of a point in a plane. Next, determine which quadrant the point belongs, or if you are over one of the Cartesian axes or the origin (x = y = 0).
If the point is at the origin, write the message "Origem".
If the point is over X axis write "Eixo X", else if the point is over Y axis write "Eixo Y".

Input

The input contains the coordinates of a point.

Output

The output should display the quadrant in which the point is.
Input SampleOutput Sample
4.5 -2.2Q4
0.1 0.1Q1
0.0 0.0Origem
Problem Link: [URI-1041##link##]

Solution

  • [tab]
    • C
      • #include<stdio.h>
        int main()
        {
            float a,b;
            while(scanf("%f %f",&a,&b)==2)
            {
        
                if(a==0 && b==0)
                    printf("Origem\n");
        
                else if(b==0)
                    printf("Eixo X\n");
        
                else if(a==0)
                    printf("Eixo Y\n");
        
                else if(a>0 && b>0)
                    printf("Q1\n");
        
                else if(a<0 && b>0)
                    printf("Q2\n");
        
                else if(a<0 && b<0)
                    printf("Q3\n");
                else
                    printf("Q4\n");
        
            }
            return 0;
        }
    • C++
      • #include <cstdio>
        
        int main()
        {
         float x;
         float y;
        
         scanf("%f", &x);
         scanf("%f", &y);
        
         if(x == 0 && y == 0){
          printf("Origem\n");
         }else if(x == 0){
          printf("Eixo Y\n");
         }else if(y == 0){
          printf("Eixo X\n");
         }else if(x > 0 && y > 0){
          printf("Q1\n");
         }else if(x > 0 && y < 0){
          printf("Q4\n");
         }else if(x < 0 && y > 0){
          printf("Q2\n");
         }else{
          printf("Q3\n");
         }
        
         return 0;
        
        }
3/Technology/post-list
Name

Codeforces,53,Problem Solve,90,Programming Tricks,1,URI,37,
ltr
item
DorHubs: URI-1041 Solve
URI-1041 Solve
https://resources.urionlinejudge.com.br/gallery/images/problems/UOJ_1041.png
DorHubs
https://dorhubs.blogspot.com/2019/09/uri-1041-solve.html
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/
https://dorhubs.blogspot.com/2019/09/uri-1041-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