*************
Main.Cpp*
************
#include <iostream.h>
#include "llist.h"
void
main()
{
int
data;
//value which passes to link
number link;
cout<<
"--------------------------------------------------------------------------\n"
<<
"Link List Program |\n"
"USAGE: Enter The Numbers From The Keyboard in random order |\n"
" Program Will give them to you in ascending order from up to bottom|\n"
"\nEnter Your Numbers:(-1 For Exit)\n"
"--->"
;
cin>>data;
while
(data>-1){
//take the values
link.add(data);
if
(data==-1){
//exit msg
"END\n"
"Those Ar The Numbers U Have Entered(Given In Ascending Order)\n"
link.print();
}
//if
//while
//main
//MasterG 2004
LList.cpp*
#include <iostream>
using
namespace
std;
number::number(){
//constructor
head=NULL;
cur=NULL;
pre=NULL;
number::add(
num){
//adding function
node *temp=NULL;
(head==NULL) {
//IsEmpty?
head=
new
node;
head->num=num;
head->next=NULL;
//end of if
else
(head->num > num){
//Is Entered Num < Head?
cur=head;
head->next=cur;
//Else Fınd The Correct Node For Entered Num
(cur && cur->num <= num){
pre=cur;
cur=cur->next;
temp=
temp->num=num;
temp->next=cur;
pre->next=temp;
//end of add func.
number::print(){
//print
"START->"
(cur!=NULL){
cout<<cur->num<<
" >"
**********
LList.h *
#ifndef LLIST_H
#define LLIST_H
struct
node{
num;
//data
node *next;
};
class
number{
public
:
//public members
number();
//constr.
add(
num);
//adding values to list
print();
private
//private members
node *head;
node *cur;
node *pre;
#endif