 |
|
04-10-2007, 07:22 PM
|
#301 (permalink)
|
|
I see right through you.
Join Date: Sep 2005
Location: Chennai
Posts: 597
|
Re: Post ur C/C++ Programs Here
The only way is to create a new list, going through each node of the previous list and inserting it at the beginning of the new list.
eg :
Code:
Node *p = head->next;
Node *revHead = head;
head = head->next;
revHead->next = NULL;
while (p != NULL) {
p = p->next;
head->next = revHead;
revHead = head;
head = p;
}
Now you have a new list, with revHead as the head node.
__________________
I didn't make the world, I only try to live in it.
http://lucentbeing.com
-- Sykora --
|
|
|
|
Advertisements. Register and be a member of the community to get rid of them.
|
|
Advertisement
|
|
04-10-2007, 07:54 PM
|
#302 (permalink)
|
|
True Techie
Join Date: Apr 2005
Posts: 260
|
Re: Post ur C/C++ Programs Here
Quote:
|
Originally Posted by Sykora
The only way is to create a new list, going through each node of the previous list and inserting it at the beginning of the new list.
eg :
Code:
Node *p = head->next;
Node *revHead = head;
head = head->next;
revHead->next = NULL;
while (p != NULL) {
p = p->next;
head->next = revHead;
revHead = head;
head = p;
}
Now you have a new list, with revHead as the head node.
|
Fine.. but lets assume that list contains some 1 lack records.. so if thats the case this program will create an overhead... any optimistic code?
|
|
|
04-10-2007, 08:52 PM
|
#303 (permalink)
|
|
I see right through you.
Join Date: Sep 2005
Location: Chennai
Posts: 597
|
Re: Post ur C/C++ Programs Here
How does it create overhead? It isn't creating new nodes, just reinserting them in a new list.
__________________
I didn't make the world, I only try to live in it.
http://lucentbeing.com
-- Sykora --
|
|
|
04-10-2007, 09:59 PM
|
#304 (permalink)
|
|
True Techie
Join Date: Apr 2005
Posts: 260
|
Re: Post ur C/C++ Programs Here
Quote:
|
Originally Posted by Sykora
How does it create overhead? It isn't creating new nodes, just reinserting them in a new list.
|
You are right.. but is it not possible to do that without creating another list?
|
|
|
04-10-2007, 10:40 PM
|
#305 (permalink)
|
|
In The Zone
Join Date: Sep 2006
Location: Kharagpur for now
Posts: 362
|
Re: Post ur C/C++ Programs Here
try this..
Code:
node *revList(node *head)
{
if(head==NULL)
return head;
node *p,*q,*r;
p=head;
while(p!=NULL){
r=q=p->next;
if(q!=NULL){
q->next=p;
p=r;
}
}
head=p;
return head;
}
__________________
http://www.last.fm/user/NOLFxceptMe/
http://naveendageek.blogspot.com
Back after a long time. And well, EndSems screwed up as usual :)
|
|
|
05-10-2007, 03:07 PM
|
#306 (permalink)
|
|
Right Off the Assembly Line
Join Date: Sep 2007
Location: Philippines
Posts: 5
|
Re: Post ur C/C++ Programs Here
My brother always use my admin account because i leave my pc on sometimes when im away or sleeping for a while.
So, I made a simple conditional statement for my brother to be reminded about the account he is using. By changing the icons of my .exe from his favorite game icon. hehe
Code:
#include <iostream>
using namespace std;
int main()
{
char Ans;
cout << "Hello!\n";
cout << "The program you have choosen has been disabled by the admin,\n";
cout << "Please use your own account,\n\n";
do{
cout << "do you want to exit (y/n)? ";
cin >> Ans;
if(Ans == 'n' || Ans =='N')
cout << "Could you please leave me now...\n\n";
else if(Ans == 'y' || Ans == 'Y')
break;
else
cout << "Invalid Entry!\n\n";
}
while(Ans != 'y' || Ans != 'Y');
system("cls");
cout << "Thank you!" << "\n\n";
cout << "Press any key to exit...";
return 0;
}
__________________
Deitel: http://wps.prenhall.com/esm_deitel_chtp_4/
FunctionX: http://www.functionx.com/index.htm
|
|
|
05-10-2007, 08:03 PM
|
#307 (permalink)
|
|
Console Junkie
Join Date: Jun 2006
Location: USA
Posts: 991
|
Re: Post ur C/C++ Programs Here
^^ ROFL   
By the way, I am working on a Library Emulation project. For my submissions. A mini project. The problem is that everyone has to do this one only (Library) and our mam wants 80 different source codes. (I am sure mine will be unique  ).
It does not use file handling. I will post it here soon.....
Aditya
PS @ Glen Apayart, I just saw you signature... You are a newbie you say, but still. There is no void main in ISO C/C++
__________________
--- Console Junkie
|
|
|
05-10-2007, 09:27 PM
|
#308 (permalink)
|
|
BlackBerry Guru ! :)
Join Date: Dec 2006
Location: New Delhi , NCR
Posts: 1,270
|
Re: Post ur C/C++ Programs Here
i m making my project for class xii...its heading its completion , last thing that i wanna do is like i m making a calendar and a billing dept. calculation center , i wanna print that on a paper using the printer ! is this possible ? if yes , then plz buddies help in coding !
__________________
Username Changed - BlackBerry7100g To BBThumbHealer ! :D
|
|
|
07-10-2007, 12:18 AM
|
#309 (permalink)
|
|
Hey here is the aks
Join Date: Jan 2006
Location: punjab
Posts: 805
|
Re: Post ur C/C++ Programs Here
Quote:
|
Originally Posted by Glen Apayart
My brother always use my admin account because i leave my pc on sometimes when im away or sleeping for a while.
So, I made a simple conditional statement for my brother to be reminded about the account he is using. By changing the icons of my .exe from his favorite game icon. hehe
Code:
#include <iostream>
using namespace std;
int main()
{
char Ans;
cout << "Hello!\n";
cout << "The program you have choosen has been disabled by the admin,\n";
cout << "Please use your own account,\n\n";
do{
cout << "do you want to exit (y/n)? ";
cin >> Ans;
if(Ans == 'n' || Ans =='N')
cout << "Could you please leave me now...\n\n";
else if(Ans == 'y' || Ans == 'Y')
break;
else
cout << "Invalid Entry!\n\n";
}
while(Ans != 'y' || Ans != 'Y');
system("cls");
cout << "Thank you!" << "\n\n";
cout << "Press any key to exit...";
return 0;
}
|
hey what does system("cls") do...?
is this a inbuilt function...? how and what is its usage..?
is this used to execute shell commands i mean dos commands..
__________________
yours truly
arun
The aks!!
have a nice day
|
|
|
07-10-2007, 06:26 AM
|
#310 (permalink)
|
|
Commander in Chief
Join Date: Jul 2005
Posts: 6,658
|
Re: Post ur C/C++ Programs Here
Quote:
|
Originally Posted by arunks
hey what does system("cls") do...?
is this a inbuilt function...? how and what is its usage..?
is this used to execute shell commands i mean dos commands..
|
Yeah it is used to execute commands, or launch other programs too perhaps.
Your current running program halts when this is called, and continues only after the command called completes execution. System() makes the code OS-Dependent.
http://www.phim.unibe.ch/comp_doc/c_...NS/system.html
|
|
|
07-10-2007, 06:58 AM
|
#311 (permalink)
|
|
Dreamweaver
Join Date: Aug 2006
Location: Bangalore
Posts: 3,904
|
Re: Post ur C/C++ Programs Here
what is typedef
__________________
Today's noobs are tomorrow's geeks. Don't make fun of them.. encourage them. - Gigacore
Follow me on twitter.com/gigacore
|
|
|
07-10-2007, 07:27 AM
|
#312 (permalink)
|
|
Commander in Chief
Join Date: Jul 2005
Posts: 6,658
|
Re: Post ur C/C++ Programs Here
Typedef is commonly used to give any Data Type a new name.
Like for example:
Code:
#include<iostream>
int main()
{
typedef int a; // Thus, a refers automatically to an integer
a abc=1, def=0; // Creates two variables of type int,
// as the typedef above shows
cout<<"ABC = "<<abc<<" DEF = "<<def<<endl;
return 0;
}
This is very useful while working with a lot of classes, or structures. You can name them comfortably or for different usages (Like we use Position and List names in a clear Linked List algorithm but both are essentially the same structure, just used with a different name to aide understanding).
Last edited by QwertyManiac; 07-10-2007 at 09:29 AM.
|
|
|
07-10-2007, 09:03 AM
|
#313 (permalink)
|
|
Dreamweaver
Join Date: Aug 2006
Location: Bangalore
Posts: 3,904
|
Re: Post ur C/C++ Programs Here
thanks qwerty
__________________
Today's noobs are tomorrow's geeks. Don't make fun of them.. encourage them. - Gigacore
Follow me on twitter.com/gigacore
|
|
|
07-10-2007, 10:12 AM
|
#314 (permalink)
|
|
Alpha Geek
Join Date: Aug 2005
Location: Kolkata
Posts: 651
|
Re: Post ur C/C++ Programs Here
can anyone give me a tutorial on how to ....do user authentication using C..is it possible...
suppose I ..have created a website ...where a member have to login...so how do I check the user verification.....
Any source code...
__________________
Visit my Blog::::::
http://shyamkol.blogspot.com
|
|
|
07-10-2007, 12:48 PM
|
#315 (permalink)
|
|
BlackBerry Guru ! :)
Join Date: Dec 2006
Location: New Delhi , NCR
Posts: 1,270
|
Re: Post ur C/C++ Programs Here
Quote:
|
Originally Posted by BlackBerry7100g
i m making my project for class xii...its heading its completion , last thing that i wanna do is like i m making a calendar and a billing dept. calculation center , i wanna print that on a paper using the printer ! is this possible ? if yes , then plz buddies help in coding !
|
wud anyone lyk to help in the above case ?
__________________
Username Changed - BlackBerry7100g To BBThumbHealer ! :D
|
|
|
08-10-2007, 01:00 PM
|
#316 (permalink)
|
|
Console Junkie
Join Date: Jun 2006
Location: USA
Posts: 991
|
Re: Post ur C/C++ Programs Here
I have been having a problem. And someone please help me as soon as you can.
I have designed a project to be submitted in the college for submission purpose. Now, the project is a library database. I have developed a little part and I am attaching it.
When I showed the program to our teacher, she said that I must use inheritance in the program. The problem is that I don't know much about it, and from whatever I read and tried to gather in the last 2 days, I have reached a conclusion that inheritance cannot be used effectively in this case.
So please please tell me where and how to use it. Else I will have to submit this one only.
Aditya
__________________
--- Console Junkie
|
|
|
08-10-2007, 06:27 PM
|
#317 (permalink)
|
|
Commander in Chief
Join Date: Jul 2005
Posts: 6,658
|
Re: Post ur C/C++ Programs Here
Sometimes in colleges, 'effective' isn't the word, its 'you have to'. So implementing it even for a basic thing would satisfy them. Just saying ..
I don't understand 'make' stuff in your files, you use Ajunta? Is coding them all into one file not a good procedure? And the use of header files etc? Wait, how do I even compile it?  Need some enlightenment on this.
|
|
|
08-10-2007, 06:36 PM
|
#318 (permalink)
|
|
Console Junkie
Join Date: Jun 2006
Location: USA
Posts: 991
|
Re: Post ur C/C++ Programs Here
Quote:
|
Originally Posted by QwertyManiac
Sometimes in colleges, 'effective' isn't the word, its 'you have to'. So implementing it even for a basic thing would satisfy them. Just saying ..
I don't understand 'make' stuff in your files, you use Ajunta? Is coding them all into one file not a good procedure? And the use of header files etc? Wait, how do I even compile it?  Need some enlightenment on this.
|
I use anjuta. You guessed right. To compile it... I dunno the sommand line method. But if you have Anjuta, then create a new project and add the files in that project. Then click on auto generate the project.
Then compile, make and build to execute.
And after reading professional C++, I have reached the conclusion that creating different files is the best way to make the program easy to understand, modify and expand.
Try if you can, else I will send you the entire project by mail. The compressed (tar.bz2) file is about 1000KB.
Aditya
__________________
--- Console Junkie
|
|
|
08-10-2007, 06:39 PM
|
#319 (permalink)
|
|
"The Cake is a Lie!!"
Join Date: Oct 2006
Posts: 471
|
Re: Post ur C/C++ Programs Here
Has anyone correctly implimented Brent-Salamin algorithm for computing Pi? I never was able to get it right
(Only thing i've done is Leibniz method of Pi, thats easy, but it takes insane amount to just calculate 10 decimal places accurately! :-/)
__________________
[xubz] ● http://xubz.com/
[steam_id] ● http://steamcommunity.com/id/xubz
|
|
|
08-10-2007, 06:42 PM
|
#320 (permalink)
|
|
die blizzard die! D3?
Join Date: Aug 2007
Location: Event horizon
Posts: 2,361
|
Re: Post ur C/C++ Programs Here
^^lol me too.I am wondering how to compile it using Dev c++.
BTW you are very good at programming Aditya and a clean programmer.
__________________
Stealing your women and horses since 1843.
|
|
|
08-10-2007, 09:33 PM
|
#321 (permalink)
|
|
Commander in Chief
Join Date: Jul 2005
Posts: 6,658
|
Re: Post ur C/C++ Programs Here
Quote:
|
Originally Posted by aditya.shevade
Try if you can, else I will send you the entire project by mail. The compressed (tar.bz2) file is about 1000KB.
|
That's okay, never mind, seems beyond my mind right now. Someone else like Yamaraj or Sykora might be able to answer it I s'pose. Am not that good really, yet
And a doubt:
Does Anjuta automatically create Header files or did you _HAVE_ to code them?
Last edited by QwertyManiac; 08-10-2007 at 09:42 PM.
|
|
|
08-10-2007, 09:44 PM
|
#322 (permalink)
|
|
Console Junkie
Join Date: Jun 2006
Location: USA
Posts: 991
|
Re: Post ur C/C++ Programs Here
^^
__________________
--- Console Junkie
|
|
|
08-10-2007, 09:47 PM
|
#323 (permalink)
|
|
Commander in Chief
Join Date: Jul 2005
Posts: 6,658
|
Re: Post ur C/C++ Programs Here
Alright, am trying my best right now. (I sure am tired after this).
Hopefully would tell you a few ways to implement inheritance into it after going through entirely.
/Me does a sudo apt-get install anjuta
Edit: You need to document your files .. Comments make it easier
Last edited by QwertyManiac; 08-10-2007 at 10:16 PM.
|
|
|
08-10-2007, 09:53 PM
|
#324 (permalink)
|
|
Console Junkie
Join Date: Jun 2006
Location: USA
Posts: 991
|
Re: Post ur C/C++ Programs Here
^^ Anjuta is very good.
And I need this by friday.
__________________
--- Console Junkie
|
|
|
10-10-2007, 08:07 PM
|
#325 (permalink)
|
|
Apprentice
Join Date: Feb 2007
Posts: 87
|
Re: Post ur C/C++ Programs Here
hey guys i needed ur help wid a c program.....
cud sm1 plzz post dis program 4 me...plzzzzz
d program is that....
it should accept any number between one and thousand and find the first non zero digit of the factorial of dat number from the right hand side.....
plz plz plz help me...
__________________
IF THIS HELPS PLEASE CLICK THE BALANCE UNDER MY ID............:wink: 8-)
|
|
|
10-10-2007, 08:14 PM
|
#326 (permalink)
|
|
18 Till I Die............
Join Date: Jul 2004
Location: India, Mumbai, Marine Lines
Posts: 5,792
|
Re: Post ur C/C++ Programs Here
Shouldn't that be easy.
1) Find the factorial
2) Divide it by 10
3) Check the remainder
4) If it's 0 discard it
__________________
http://www.bash.org/?258908
|
|
|
10-10-2007, 08:44 PM
|
#327 (permalink)
|
|
Apprentice
Join Date: Feb 2007
Posts: 87
|
Re: Post ur C/C++ Programs Here
d question is which datatype 2 use....
v are talkin abt d factorial of even 1000....
so ders no datatype which can store dat....finding factorial is impossible....
hey guys i needed ur help wid a c program.....
cud sm1 plzz post dis program 4 me...plzzzzz
d program is that....
it should accept any number between one and thousand and find the first non zero digit of the factorial of dat number from the right hand side.....
plz plz plz help me...
__________________
__________________
IF THIS HELPS PLEASE CLICK THE BALANCE UNDER MY ID............:wink: 8-)
Last edited by vinit suri; 10-10-2007 at 08:44 PM.
Reason: Automerged Doublepost
|
|
|
10-10-2007, 08:48 PM
|
#328 (permalink)
|
|
die blizzard die! D3?
Join Date: Aug 2007
Location: Event horizon
Posts: 2,361
|
Re: Post ur C/C++ Programs Here
You can use exponential form i.e. aeb= a into e raised to the power b.Its limits is from -3.4e38 to 3.4e38.Hope this helps.I have never used it so don't ask how to implement it.
BTW your question looks like picked up from CAT or something.I'm sure of some trick involved.
__________________
Stealing your women and horses since 1843.
|
|
|
10-10-2007, 09:11 PM
|
#329 (permalink)
|
|
Console Junkie
Join Date: Jun 2006
Location: USA
Posts: 991
|
Re: Post ur C/C++ Programs Here
^^ trick might be that, if you multiply by 1000 then the first non zero from right cannot be 1 to 3 as there will be three zeros already. Also, for 1000, you will have 990 so add one more zero, 980 another zero and so on.
It's not easy this way, but worth a try.
__________________
--- Console Junkie
|
|
|
10-10-2007, 09:19 PM
|
#330 (permalink)
|
|
Console Junkie
Join Date: Jun 2006
Location: USA
Posts: 991
|
Re: Post ur C/C++ Programs Here
Quote:
|
Originally Posted by QwertyManiac
Edit: You need to document your files .. Comments make it easier 
|
Actually, even I thought I should but after a couple of my friends who are not very good at C/C++ also understood the code just be the names of the variables, I think I can save the trouble.
So, I just added a naming conventions file as a documentation, and forgot to add it in the zip archive.
Here it is by the way, if you would like.
Aditya
__________________
--- Console Junkie
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|