Posts

URI ONLINE JUDGE SOLUTION 1044 - Multiples

Image
Problem Read two nteger values (A and B). After, the program should print the message "Sao Multiplos" (are multiples) or "Nao sao Multiplos" (aren’t multiples), corresponding to the read values. Input The input has two integer numbers. Output Print the relative message to the input as stated above. Solution C programming source code for uri online judge beginner problem 1044-Multiples: #include<stdio.h> int main() {     int a,b;     scanf("%d%d",&a,&b);     if(a%b==0 || b%a==0)         printf("Sao Multiplos\n");     else         printf("Nao sao Multiplos\n");     return 0; } How it works? This is the beginner level  problem of uri online judge.Here you would have to check if one the number is dividable by other one.If it is then you should print the first message if not then you should print the second message.Hopefully you would understand the problem.Don't copy paste the code as s

URI ONLINE JUDGE SOLUTION 1043 - Triangle

Image
Problem Read three point floating values (A, B and C) and verify if is possible to make a triangle with them. If it is possible, calculate the perimeter of the triangle and print the message: Perimetro = XX.X If it is not possible, calculate the area of the trapezium which basis A and B and C as height, and print the message: Area = XX.X Input The input file has tree floating point numbers. Output Print the result with one digit after the decimal point. Solution C programming source code for uri online judge beginner problem 1043 - Triangle: #include<stdio.h> int main() {     double a,b,c;     scanf("%lf%lf%lf",&a,&b,&c);     if(a+b>c && b+c>a && c+a>b)         printf("Perimetro = %0.1lf\n",a+b+c);     else         printf("Area = %0.1lf\n",0.5*(a+b)*c);     return 0; } How it works? This is the beginner level  problem of uri online judge.Here you would have to check if it i

URI ONLINE JUDGE SOLUTION 1042 - Simple Sort

Image
Problem Read three integers and sort them in ascending order. After, print these values in ascending order, a blank line and then the values in the sequence as they were readed. Input The input contains three integer numbers. Output Present the output as requested above. Solution C programming source code for uri online judge beginner problem  1042 - Simple Sort #include<stdio.h> int main() {     int val[3],sort[3],i,j,temp;     for(i=0;i<3;i++){         scanf("%d",&val[i]);         sort[i]=val[i];}     for(i=0;i<2;i++){         for(j=0;j<2;j++){         if(sort[j]>sort[j+1]){          temp=sort[j+1];          sort[j+1]=sort[j];          sort[j]=temp;}            }     }     for(i=0;i<3;i++)     printf("%d\n",sort[i]);     printf("\n");     for(i=0;i<3;i++)     printf("%d\n",val[i]);     return 0; } How it works? This is the beginner level problem of uri online judge.Here y

URI ONLINE JUDGE SOLUTION 1041 - Coordinates of a Point

Image
Problem 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. Solution #include<stdio.h> int main() {     double x,y;     scanf("%lf%lf",&x,&y);     if(x == 0 & y == 0)         printf("Origem\n");     if(y == 0 && x!=0)         printf("Eixo X\n");     if(x == 0 && y!=0)         printf("Eixo Y\n");     if(x > 0 && y > 0)         printf("Q1\n");     if(x < 0

URI ONLINE JUDGE SOLUTION 1040 - Average 3

Image
Problem Read four numbers (N 1 , N 2 , N 3 , N 4 ), which one with 1 digit after the decimal point, corresponding to 4 scores obtained by a student. Calculate the average with weights 2, 3, 4 e 1 respectively, for these 4 scores and print the message "Media: " (Average), followed by the calculated result. If the average was 7.0 or more, print the message "Aluno aprovado." (Approved Student). If the average was less than 5.0, print the message: "Aluno reprovado." (Reproved Student). If the average was between 5.0 and 6.9, including these, the program must print the message "Aluno em exame." (In exam student). In case of exam, read one more score. Print the message "Nota do exame: " (Exam score) followed by the typed score. Recalculate the average (sum the exam score with the previous calculated average and divide by 2) and print the message “Aluno aprovado.” (Approved student) in

URI ONLINE JUDGE SOLUTION 1038 - Snack

Image
Problem Using the following table, write a program that reads a code and the amount of an item. After, print the value to pay. This is a very simple program with the only intention of practice of selection commands. Input The input file contains two integer numbers X and Y . X is the product code and Y is the quantity of this item according to the above table. Output The output must be a message "Total: R$ " followed by the total value to be paid, with 2 digits after the decimal point. Solution #include<stdio.h> int main() {     int x,y;     double total = 0.0;     scanf("%d%d",&x,&y);     if(x == 1){         total = y*4.0;     }     if(x == 2){         total = y*4.5;     }     if(x == 3){         total = y*5.0;     }     if(x == 4){         total = y*2.0;     }     if(x == 5){         total = y*1.5;     }     printf("Total: R$ %0.2lf\n",total);     return 0; } Solution Tricks:Suppose,There are

URI ONLINE JUDGE SOLUTION 1037 - Interval

Image
Problem 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. Solution #include<stdio.h> int main() {     double x;     scanf("%lf",&x);     if(x >= 0 &&