![]() |
Certain operations on linked list elements - How to?
Hi, all!
First, I've used search on this forum for my problem and found some very good articles about linked list, but nothing that can help me. So, is it possible to write function in C for adding two adjoining elements of the list? And to start that adding from second element of the list, so the first one stays the same? Here is what I need to do: If elements of the list are: a5, a4,...a1, I need to get the following elements: b4=a5, b3=x*b4+a4,..., b1=x*b2+a2, b0=x*b1+a1, where x is integer value argument of the function. Here is what I've tried: Code:
struct niz *amnoz(struct niz *a,int m, int n) Can this be done with single linked list, or do I have to use doble linked list? Thanks in advance! |
Re: Certain operations on linked list elements - How to?
I've solved the problem:
Code:
struct niz *bform(struct niz *koef, int n, int a)So, how can I fix this? Thanks. |
Re: Certain operations on linked list elements - How to?
hi pseudobluz,
sorry..i din referred to ur code...but understanding the problem description i have designed the program for u...try to understand it ..if u cnt then ask me frankly...it is working perfectly..(designed and verified myself) Code:
# include<stdio.h> |
Re: Certain operations on linked list elements - How to?
Thanks! I'll take a look at your code and try to fix mine. What I'm trying to do is write prog for Horner's rule via singly linked lists. Once I repair my code I'll post the results.
|
Re: Certain operations on linked list elements - How to?
UPDATE:
I've just tried to compile your code and it went smoothly but there is the same runtime error as before on line: ptr->info=x*temp + ptr->info; You said this code works so I guess it has something to do with compiler? Which one are you using? |
Re: Certain operations on linked list elements - How to?
i m using turbo c++...whatever the compiler u use for c..u wnt get the error as far as my code is concerned...
try this:- (ptr->info)=(x*temp) + (ptr->info) if still u get error then i will upload the c file in rapidshare...inform me asap becoz i m astounded by the fact that u got error..i have checked my code 10 more times but getting the code running for all input sample...nd one more thing this program is based on singly linked list...if u want the same program using doubly linked list then that also i can upload for u...i kept the basic concept while designing the code...IT WORKS FINE!! |
Re: Certain operations on linked list elements - How to?
ohk..i m giving u the rapidshare link of the zip file containing MY CODE as well as EXE file.
run the exe file nd get confirmed...i think u have got something wrong with ur compiler.. http://rapidshare.com/files/324019864/linklist.rar.html |
Re: Certain operations on linked list elements - How to?
I can not run your exe file. I've got the error about program incompatibillity with my x64 os.
That is probably due the program being compiled on 32-bit OS? So I've opened your c file, tried to compile it and received the same error as before, so most definitely it's compiler related problem. I will try Turbo C++ and some other compilers, and report the resulits once I'm done. This problem became pretty irritating for me, since I can not solve it for days, and it's such a simple program. And I have previous experince in programming much complicated stuff in C/C++/C#. However it's been some time since my last program :) Once more, thank you very much for you effort. I'll update this topic once I test all the other compilers. |
Re: Certain operations on linked list elements - How to?
Now I've tried Dev C++. Still the same. Can you please try to compile this code on your rig:
http://rapidshare.com/files/324105295/cprog.c.html Ignore any comments. Those are in my native language, so you won't understand probably. |
Re: Certain operations on linked list elements - How to?
your program is working file without any compilation error...it also executed well..i couldnt check the logic becoz the print comments were in ur native language...can u make it in english for me so that i can check ur logic..?? UR PROG WORKS FINE!!
|
| All times are GMT +5.5. The time now is 04:28. |