MPGH Logistic Programming Challenge
Even pascal's triangle isn't that hard as well.
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n;
int i;
int j;
printf("How big is your triangle?: ");
scanf("%d", &n);
for (i=0; i<n; i++) {
int c = 1;
for(j=i; j>=0; j--) {
printf(" %d", c);
c = c * j/(i-j+1);
}
printf("\n");
}
}
I ARE PASS
[php]#include <iostream>
using namespace std;
int fibonacci(int nth);
int main()
{
int nth, result;
cout << "Place in sequece?\n";
cin >> nth;
result = fibonacci(nth);
cout << result;
}
int fibonacci(int nth)
{
if(nth < 3)
{
return 1;
}
else
{
return fibonacci(nth-2) + fibonacci(nth-1);
}
}
[/php]
[php]#include <iostream>
using namespace std;
int fibonacci(int nth);
int main()
{
int nth, result;
cout << "Place in sequece?\n";
cin >> nth;
result = fibonacci(nth);
cout << result;
}
int fibonacci(int nth)
{
if(nth < 3)
{
return 1;
}
else
{
return fibonacci(nth-2) + fibonacci(nth-1);
}
}
[/php]
You guys' Code will fail on a certain point if you use 32 Bits Integers.
Use __Int64, They can hold wayyy more data, And your thingy can go waaay Further =).
Int Max/Min 2147483647 / -2147483648
__Int64 Max/Min 9223372036854775807 / -9223372036854775808
Use __Int64, They can hold wayyy more data, And your thingy can go waaay Further =).
Int Max/Min 2147483647 / -2147483648
__Int64 Max/Min 9223372036854775807 / -9223372036854775808
I tried it and it works.
But my program still hangs if a number in the sequence entered is larrger than 38
[php]#include <iostream>
using namespace std;
_int64 fibonacci(_int64 nth);
int main()
{
_int64 nth, result;
cout << "Place in sequece?\n";
cin >> nth;
result = fibonacci(nth);
cout << result;
}
_int64 fibonacci(_int64 nth)
{
if(nth < 3)
{
return 1;
}
else
{
return fibonacci(nth-2) + fibonacci(nth-1);
}
}
[/php]
But my program still hangs if a number in the sequence entered is larrger than 38

[php]#include <iostream>
using namespace std;
_int64 fibonacci(_int64 nth);
int main()
{
_int64 nth, result;
cout << "Place in sequece?\n";
cin >> nth;
result = fibonacci(nth);
cout << result;
}
_int64 fibonacci(_int64 nth)
{
if(nth < 3)
{
return 1;
}
else
{
return fibonacci(nth-2) + fibonacci(nth-1);
}
}
[/php]
Similar Threads
Coders Lounge[Idea][Discussion] Programming Challenges.
67 Combat Arms Mod DiscussionMPGH Login Background Challenge!
52 Combat Arms Mod DiscussionThe Mpgh Login Background Challenge!! Deadline: 9/5!!
65 Combat Arms Mods & Rez ModdingThe Mpgh Login Background Challenge!! Deadline: 9/5!!
10 Combat Arms Mod DiscussionThe Mpgh Login Background Challenge Poll!! VOTE NOW
68



.
, I know noone cares but it IS just logic so programming language doesn't matter 




.