Originally Posted by
treenef
It works on my version of Dev-shed, but what should I be doing different so that it works with every compiler within reason?
If you declare a function returning int, it should return an int.
Here are two possible changes to fix your code:
Code:
void catalan(int n)
{
char array[81][81]={"1","2","5","14","42","132","429","1430","4862",
"16796","58786","208012","742900","2674440","9694845",
"35357670","129644790","477638700","1767263190"};
cout<<array[n-1];
}
Code:
int catalan(int n)
{
//Store the numbers as INTEGERS, not strings!
//Numbers should be stored as numbers
int array[81]={1,2,5,14,42,132,429,1430,4862,
16796,58786,208012,742900,2674440,9694845,
35357670,129644790,477638700,1767263190};
cout<<array[n-1];
return array[n-1];
}