Total members 9952 | Gratitudes |It is currently Sat Feb 11, 2012 3:15 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Question
 Question subject: a code that will be usefull to pepople learning basics in c!
PostPosted: Mon Dec 14, 2009 10:50 pm 
Offline
Moderator
User avatar

Joined: Fri Nov 21, 2008 6:18 pm
Posts: 51
Location: thessaloniki
Has thanked: 0 time
Have thanks: 2 time

insertsort list
= ->
Code:
void insertSortList(LIST *L, int x)
{
NODE *nextptr,*previus,*newptr;
nextptr=Lhead;
previus=nextptr;
if(nextptr==NULL)
{
newptr=(NODE*) malloc(sizeof(NODE));
newptrdata=x;
newptrnext=Lhead;
Lhead=newptr;
Lsize++;
return;
}
else if(x<Lheaddata)
{
newptr=(NODE*) malloc(sizeof(NODE));
newptrdata=x;
newptrnext=Lhead;
Lhead=newptr;
return;
}
else{
while ((nextptr != NULL )&& ((nextptrdata) < x ))
{
previus = nextptr;
nextptr = nextptrnext;
}
newptr=(NODE *)malloc(sizeof(NODE));
newptrdata=x;
newptrnext=nextptr;
previusnext=newptr;
Lsize++;
return;
}
}
void deleteNode(LIST *L, int x)
{
NODE *nextptr, *previus;
nextptr = Lhead;
if (nextptrdata == x)
{ //the head is treated separately
Lhead = nextptrnext;
Lsize--;
free(nextptr);
return;
}
else
{
while (nextptr != NULL)
{ //find x and delete it
if (nextptrdata == x)
{ //value found
Previusnext =nextptrnext;
free(nextptr);
Lsize--;
return;
}
previus = nextptr; //use *previus as the previous position pointer
nextptr = nextptrnext;
}
}
}//delete







_________________
if you want make an effort yourself no one will make it for you...
best regards


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  


 Similar topics
 Topic title   Forum   Author   Comments 
 java project code  Java  Anonymous  0
 Read your gmail using Java code  Java examples  msi_333  5
 What's wrong with my code?  Java  Anonymous  3
 project source code in java  Java  Anonymous  0
 Ajax Source code to Suggest application with JSP Server side  AJAX  msi_333  5

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team