URI

Solution (Simple Product) of URI online judge problem 1004 by c++

Make a simple problem that only read two integer values. After that, calculate the product between them and store the result in a variable named PROD. Print the result like the sample below. Do not forget to print the end line after the result otherwise you will get “Presentation Error”.

Input

The input file will contain 2 integer numbers.

Output

Print PROD according to the following example, with a blank space before and after the equal signal.

Sample Inputs Sample Outputs
3
9
PROD = 27
-30
10
PROD = -300
0
9
PROD = 0

Solution:

#include<iostream>
using namespace std;

int main(){
int a, b, r;
cin>>a>>b;
r=a*b;
cout<<“PROD = “<<r<<endl;
}

Advertisements
Categories: URI | Leave a comment

Solution (Simple Sum) of URI online judge problem 1003 by c++

Read two variables A and B. Next, calculate the sum between them and assign it to the variable SOMA. Write the value of this variable.

Input

The input file will contain 2 integer numbers.

Output

Print SOMA according to the following example, with a blank space before and after the equal signal.

Samples Input Samples Output
30
10
SOMA = 40
-30
10
SOMA = -20
0
0
SOMA = 0

Solution:

#include<iostream>

using namespace std;

int main(){
int a, b, soma;
cin>>a>>b;
soma=a+b;
cout<<“SOMA = “<<soma<<endl;
return 0;
}

Categories: URI | Leave a comment

Solution (Area of a Circle) of URI online judge problem 1002 by c++

The area of the circle is defined as A = π . R2, having π as 3.14159.

Calculate the area using the formula given in the problem description.

Input

Read the variable R (double precision), that is the radius of the circle.

Output

Print the variable A, rounded to four decimal digits.

Sample Inputs Sample Outputs
2.00 A=12.5664
100.64 A=31819.3103
150.00 A=70685.7750

Solution:

#include<iostream>
#include <iomanip>
using namespace std;
int main(){
double R, A, pi;
pi=3.14159;
cin>>R;
A=pi*(R*R);
cout<<“A=”<<fixed<<setprecision(4)<<A<<endl;
return 0;
}

Categories: URI | Leave a comment

Create a free website or blog at WordPress.com.