Search found 6 matches
- Tue Jan 10, 2012 12:25 pm
- Forum: Computer Science
- Topic: Camp on Contest Programming
- Replies: 6
- Views: 4859
Re: Camp on Contest Programming
If any one of you have difficulty finding a residence for the camp, let us know. We might be able to help you.
- Sun Jan 08, 2012 11:09 pm
- Forum: Computer Science
- Topic: Calculating Trigonometric Functions
- Replies: 13
- Views: 15733
Re: Calculating Trigonometric Functions
Instead of declaring i in the for loop, you can declare i before. Like -
Code: Select all
int i;
for(i = 1; i <= 100; i+=2) {
}
- Sun Jan 08, 2012 10:27 pm
- Forum: Computer Science
- Topic: Calculating Trigonometric Functions
- Replies: 13
- Views: 15733
Re: Calculating Trigonometric Functions
Okay, here's a somewhat simpler and inefficient version - double factorial(int n) { double res = 1; for(int i = 1; i <=n; i++) { res = res * n; } return res; } double sin(double x) { double res = 0; int sign = 1; for(i = 1; i <= 100; i+=2) { double num = pow(x, i); double denom = factorial(i); res =...
- Sun Jan 08, 2012 9:27 pm
- Forum: Computer Science
- Topic: Calculating Trigonometric Functions
- Replies: 13
- Views: 15733
Re: Calculating Trigonometric Functions
Let me explain my code in a more detail //we will write a function to calculate sine of a given value //we will use MacLaurin Series for this purpose //sinx = x - x^3 / 3! + x^5 / 5! - ...... double sin(double x) { double res = 0; //result variable int sign = 1; //sign of a particular term in the se...
- Sun Jan 08, 2012 3:33 pm
- Forum: Computer Science
- Topic: Calculating Trigonometric Functions
- Replies: 13
- Views: 15733
Re: Calculating Trigonometric Functions
Write something like -
Code: Select all
double sin(double x) {
double res = 0;
int sign = 1;
double denom = 1;
double num = x;
for(i = 1; i <= 100; i+=2) {
res += (sign * num) / denom;
num *= (x*x);
denom *= ((i+1)*(i+2));
sign *= -1;
}
return res;
}
- Sun Jan 08, 2012 12:12 pm
- Forum: Computer Science
- Topic: Camp on Contest Programming
- Replies: 6
- Views: 4859
Camp on Contest Programming
There will a 5 day camp on contest programming at BUET from Jan 15 to Jan 19, 2012. We'd like to see as many school / college students as possible. So, if you're interested about problem solving, math and algorithm and know a bit of C/C++ or Java, you can join. Registration will be open up to Jan 10...