Diberdayakan oleh Blogger.
"DbClix"BismaClix.com - Inovasi Baru PTC Indonesia"Zonaclix - A Place to Earn online!"DbClix"Zonaclix - A Place to Earn online!"BismaClix.com - Inovasi Baru PTC Indonesia"Bux7"" ""SentraClix" lind4clix"Smileclix - PTC Indonesia dengan support profesional!

Selasa, 07 Juni 2011

linked list

mengulangi data

#include<iostream>
using namespace std;
void main(){
    struct node
    {
        int data;     //will store information
        node*next;    //the reference to the next node

    };
    node*head=NULL;    //create head
    node*newNode;      //create a temporary node
    int nilai=10;
    char ulang;

    //add@front
    newNode=(node*)malloc(sizeof(node));//allocate space for node
    newNode->data=nilai;
    newNode->next=head;
    head=newNode;
    do {
    //add@front
    newNode=(node*)malloc(sizeof(node));//allocate space for node
    newNode->data=nilai;
    newNode->next=head;
    head=newNode;

    //cetak isi linked list
    cout<<"\n Isi List:";
    node*temp;
    temp=head;//transfer the address of 'temp' to 'head'
    while(temp!=NULL)
    {
        cout<<temp->data<<"\t";//show the data in the linked list
        temp=temp->next; //transfer the address if 'temp->next' to 'temp'
    }
    cout<<"\nulang lagi(y/t:";cin>>ulang;
    nilai++;
    }
    while(ulang=='y');

    system("pause");
}

Comments :

0 komentar to “linked list”

Posting Komentar

 

Copyright © 2009 by Bisnis Online

Template by Blogger Templates | Powered by Blogger