| Sajha.com Archives | ![]() |
| Username | Post |
| snakebite | Posted
on 23-Jul-03 09:14 AM
I have a function: void premute_gen(int a, int k, int n); in the main I have function call: premute_gen(a, 1, n); and the function is, void premute_gen(int a, int k, int n) { } when I compile it, I get an error message like b.cpp: In function `int main()': b.cpp:22: implicit declaration of function `int premute_gen(...)' b.cpp: In function `void check_derange(int *, int)': b.cpp:64: implicit declaration of function `int special_check(...)' any idea what's wrong with it? |
| snakebite | Posted
on 23-Jul-03 09:18 AM
Correction: have a function: void premute_gen(int a[], int k, int n); in the main I have function call: premute_gen(a, 1, n); and the function is, void premute_gen(int a[], int k, int n) { } when I compile it, I get an error message like b.cpp: In function `int main()': b.cpp:22: implicit declaration of function `int premute_gen(...)' b.cpp: In function `void check_derange(int *, int)': b.cpp:64: implicit declaration of function `int special_check(...)' any idea what's wrong with it? |
| thapaktm | Posted
on 23-Jul-03 12:36 PM
Check line 22 and 64. those functions should not return int. if that is not the case please paste line 22 and 64 then i might be albe to help you. |
| Echoes | Posted
on 23-Jul-03 12:53 PM
snakebite, I might be able to help you debug your program, but I need to see the entire source file (b.cpp) and any "your" header (.h) files, if you have. The fragment you have posted isn't all the informative, particularly because it doesn't tell if/where the erroneous lines are part of what you've posted. Post them and I try to help you. Also, please mention the compiler you are using. |
| Echoes | Posted
on 23-Jul-03 01:41 PM
Apparently, Sajha.com doesn't like certain C++ statements, so I'm posting an image of the source code I mentioned in the previous post. I'm positive your error lies somewhere else, so you must post the entire source code if you still need help.
|
| snakebite | Posted
on 23-Jul-03 01:43 PM
Echo brother!!! Thanks for your time, I posted it when I was really desperate. Now, it seems to be working....!!! Call me a dumb, but I fkd up my spelling! ;) Works just fine now... thanks!!! |
| snakebite | Posted
on 24-Jul-03 07:15 AM
Echoes, Here is one more thing probably you can put some lights on. a. Walk the array from beginning to end b. if the contents of any element is equal to the index of that element, then this array of Integers is not derangement. c. else, this array is derangement. lets say a[1] =1, a[2] =2, a[3] =3; using the for -loop for(int i=0; i<3; i++) cout< cout < lets say this produces output!! cool. using other functions, the output is lets say. 1 2 3 2 3 1 3 1 2 since, 1 is at the position a[1] in the original array, I don't want 1 2 3 to be the output.. How you gonna get rid of 123 and keep 231 and 312? I am just lost somewhere keeping track of it. |
| snakebite | Posted
on 24-Jul-03 07:16 AM
using the for -loop for(int i=0; i<3; i++) cout-- a[i]; cout endl; |
| Echoes | Posted
on 24-Jul-03 08:48 AM
Hope I am not doing your homework for you! :-) Ok...you might get some ideas from this program that I just wrote for you:
|
| Echoes | Posted
on 24-Jul-03 09:02 AM
I notice I typed the text in the source code the other way around (is/is NOT). You should have been able to figure that out, but let me show you the correct version anyway:
|
| snakebite | Posted
on 24-Jul-03 09:12 AM
Echoes, thanks again!!! Actually yes, It's my homework. But I am done already. I used the following code, and it works just fine! I was working on it yesterday night, and it was not working out, so I posted in order to get some ideas. You are genius and very helpful, thanks again!!
I'd email, if it's okay with you, rather than wasting space in sajha. thanks!! |
| Echoes | Posted
on 24-Jul-03 09:28 AM
Yes, you can email me: deepak@cs.niu.edu By the way, you might want to change your code to the following. In your current model, if you had 100 entries in your array you would need 100 logical OR (||)s. That is not a good programming practice. Plus, your "i++;" is never executed because it follows a 'break;'. Change it to the following: for (int i=1; i<=n; i++) { if (a[i] == i) break; cout << a[i] << " "; } This should give you the exact same output and it will also handle n number of entries in the array without you having to type if (a[1]==1) ||, etc. for each of them. Hope you get the idea. |
| Arnico | Posted
on 24-Jul-03 10:23 AM
Nice to see some fellow programmers here. Just curious... is anyone around with a lot of Fortran experience? I have to use a lot of legacy code dating back to the 70's, and although I use Fortran 95, some of the code I have to deal with was written in Fortran 77. |
| snakebite | Posted
on 24-Jul-03 11:11 AM
echo dude, check your email ;) |
| Echoes | Posted
on 24-Jul-03 12:16 PM
I've changed a couple of your functions and have fixed your program... Check your email for the source code, and here is the produced output, which matches the one you said you needed.: [deepak@deepakLinux tests]$ a Enter a digit n: 4 2 1 4 3 special case. 2 3 4 1 2 4 1 3 special case. 3 1 4 2 3 4 1 2 3 4 2 1 4 3 2 1 4 3 1 2 4 1 2 3 special case. [deepak@deepakLinux tests]$ a Enter a digit n: 3 2 3 1 3 1 2 [deepak@deepakLinux tests]$ |
| confused | Posted
on 24-Jul-03 01:19 PM
dudes u all look like c++ geniuses..me just strating my first lessons like hello world and the guessing game:( i am learning on my own so dont know how far will i go..but this is getting hard..i am getting very confused about float and double float..ahh well i will figure is out some how..just keep on continuing this posts..so i also can grab something out of it.. |
| snakebite | Posted
on 02-Aug-03 11:01 AM
Echoes dude, check your email... ;) |