here is another contributor: Mauri Wilde
welcome Mauri
you can follow him here: https://plus.google.com/107222474122470886478/posts
Wednesday, October 16, 2013
welcome Quan
we welcome our new contributor, Quan. welcome bro.
you can follow him on http://codeforces.com/submissions/quandum
he is a programming prodigy
you can follow him on http://codeforces.com/submissions/quandum
he is a programming prodigy
Tuesday, October 15, 2013
uri online judge 1006 solution in c++
uri online judge 1006 solution in c++
here is uri online judge 1006 problem: http://www.urionlinejudge.com.br/judge/en/problems/view/1006
and here is my c++ solution to uri online judge 1006: http://ideone.com/w8z8gX
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
float A, B, C, MEDIA;
cin >> A >> B >> C;
MEDIA = ((A * 2) + (B * 3) + (C * 5)) / (2 + 3 + 5);
cout << fixed << setprecision(1);
cout << "MEDIA = " << MEDIA << endl;
return 0;
}
here is uri online judge 1006 problem: http://www.urionlinejudge.com.br/judge/en/problems/view/1006
Average 2
Read three numbers (variables A, B and C), which are the test scores of a student. Then, calculate the average, knowing that the note A has a weight of 2, the note B has a weight of 3 and the note C has a weight of 5. Consider that each note can go from 0 to 10.0, always with one decimal place.
Input
The input file contains 3 floating-point numbers with one digit after the decimal point.
Output
Print MEDIA(average in portuguese) according to the following example, with a blank space before and after the equal signal.
| Sample Input | Sample Output |
| 5 6 7 | MEDIA = 6.3 |
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
float A, B, C, MEDIA;
cin >> A >> B >> C;
MEDIA = ((A * 2) + (B * 3) + (C * 5)) / (2 + 3 + 5);
cout << fixed << setprecision(1);
cout << "MEDIA = " << MEDIA << endl;
return 0;
}
uri online judge 1005 solution in c++
hello folks, it is really getting funny
here is uri online judge 1005 problem: http://www.urionlinejudge.com.br/judge/en/problems/view/1005
and here is my solution in c++ for uri online judge 1005: http://ideone.com/d80A5r
here is uri online judge 1005 problem: http://www.urionlinejudge.com.br/judge/en/problems/view/1005
Average 1
Make a simple program that read two floating numbers corresponding to two tests for a student. After, calculate the average between them, considering that the first number has 3.5 weight and the second one have 7.5 weight. Each number can be from zero to ten, always with one digit after the decimal point. Don’t forget to print end line after the result otherwise you will get “Presentation Error”. Don’t forget the space before and after the equal sign.
Input
The input file will contain 2 floating-point numbers with one digit after the decimal point.
Output
Print MEDIA(average in portuguese) according to the following example, with 5 digits after the decimal point and a blank space before and after the equal signal.
| Sample Input | Sample Output |
| 5.0 7.1 | MEDIA = 6.43182 |
and here is my solution in c++ for uri online judge 1005: http://ideone.com/d80A5r
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main() {
- double x, y, MEDIA;
- cin >> fixed >> setprecision(1);
- cin >> x >> y;
- MEDIA = ((x * 3.5) + (y * 7.5)) / (3.5 + 7.5);
- cout << fixed << setprecision(5);
- cout << "MEDIA = " << MEDIA << endl;
- return 0;
- }
uri online judge 1002 solution (finally :)
yes i solved it eventually after many attemps
you need to know that
you need to know that
Number of digits after the decimal point
needs to use double, because
Wrong Answer in simple problem using floating-point
Try to use double instaed float in C++. This is a common error due the precision of each one of them.
here is the uri online judge 1002 problem: http://www.urionlinejudge.com.br/judge/en/problems/view/1002
Area of a Circle
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.
Calculate the area using the formula given in the problem description.
Input
Read the variable R, that is the radius of the circle.
Output
Print the variable A, rounded to four decimal digits.
| Sample Input | Sample Output |
| 2 | A=12.5664 |
and here is my solution in c++: http://ideone.com/lQPoPh
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int main() {
- double A, p = 3.14159, R;
- cin >> R;
- A = p * R * R;
- cout << fixed << setprecision(4);
- cout << "A=" << A << endl;
- return 0;
- }
and here is another solution in c++: http://ideone.com/hiebng
#include <iostream>
#define pi 3.14159
using namespace std;
long double r,area;
int main(){
cin>>r; area=(r*r)*pi;
cout.setf(ios::fixed,ios::floatfield);
cout.precision(4);
cout <<"A=" << area;
return 0;
}
(the above shown solution belongs to Quan Tran.)
number of digits after decimal point in c++
they say, using c++ i can put n digits after decimal point: http://www.urionlinejudge.com.br/judge/helps
In the main (before print the output, in any place), use:
note: i havent tried it yet. but after trying if it really work, then i will let you now.
Number of digits after the decimal point
Using C++, this is one of the possible ways to format a number with 5 digits after the decimal point:
1
| #include <iomanip> |
1
| cout << fixed << setprecision(5); |
note: i havent tried it yet. but after trying if it really work, then i will let you now.
uri online judge 1004 solution
here is uri online judge 1004 problem: http://www.urionlinejudge.com.br/judge/en/problems/view/1004
here is my solution: http://ideone.com/15YjWH
#include <iostream>
using namespace std;
int main() {
int x, y, PROD;
cin >> x >> y;
PROD = x * y;
cout << "PROD = " << PROD << endl;
return 0;
}
my note: before solution i ranked 4073 generally, now i rank 3836 generally
Simple Product
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 Input | Sample Output |
| 3 9 | PROD = 27 |
here is my solution: http://ideone.com/15YjWH
#include <iostream>
using namespace std;
int main() {
int x, y, PROD;
cin >> x >> y;
PROD = x * y;
cout << "PROD = " << PROD << endl;
return 0;
}
my note: before solution i ranked 4073 generally, now i rank 3836 generally
Subscribe to:
Posts (Atom)