czwartek, 24 grudnia 2009

Implementacja listy dwukierunkowej w języku C++ (obiektowo)

#include
using namespace std;

class node{
public:
int value;
class node *next;
class node *prev;

node(int v){  //konstruktor
value=v;
}
};

class node *head=NULL;
class node *element=NULL;
class node *temp=NULL;


class node *push(class node *head, int val)
{
    if(head==NULL)
    {
     head =new node(val);  // nowy obiekt klasy node
     //head->value=val;
     head->prev=NULL;
     head->next=NULL;
     temp=head;
      return head;
     }else{
     element=new node(val);
     //element->value=val;
     element->prev=temp;
     temp->next=element;
     element->next=NULL;
     temp=element;
     }
   

}





void show(class node *head){

while(head!=NULL){
cout<<(head->value)<<"\n";
head=head->next;
}

}








int main(){

int value;

for(int i=0;i<10;i++)
{
head=push(head, i);
}

show(head);


}

niedziela, 1 listopada 2009

Jak ZA darmo doładować konto w telefonie

Jak doładować swój telefon za darmo? Z darmowe-doladowania.com to proste! Nie musisz sie rejestrować, wystarczy, że wyślesz Twój link do 25 znajomych a darmowe doładowanie może być Twoje!

WYSTARCZY SIĘ ZAREJESTROWAĆ PONIŻEJ : DZIAŁA
http://darmowe-doladowania.com/

wtorek, 29 września 2009

Implementacja palindromu

Implementacja listy jednokierunkowej bez "->"

#include 
#include 
#include 

struct lista{
int key;
struct  lista *next;
};
struct  lista *head=NULL;
struct  lista *tmp=NULL;
struct  lista *element=NULL;

struct lista *push(struct lista *head,int x){

if(head==NULL){
head=(struct lista*)malloc(sizeof(struct lista));
tmp=(struct lista*)malloc(sizeof(struct lista));
 (*head).key=x;
(*head).next=NULL;
//head->key=x;
//head->next=NULL;
tmp=head;

}else{

element=(struct lista*)malloc(sizeof(struct lista));
(*element).key=x;
//element->key=x;
(*element).next=NULL;
//element->next=NULL;
//tmp->next=element;
(*tmp).next=element;
tmp=element;

}

return head;

}

void wyswietl(struct lista *head){

while(head){

//printf("%d",(*head).key);
printf("%d", (*head).key);
(head)=(*head).next;
}
}


int main(){
system("cls");
int x;
int n; 

printf("Ile elementow dodac \n");
scanf("%d",&n);
for(int i=0;i<(n);i++){
scanf("%d",&x);
head=push(head,x);
}

wyswietl(head);

}

Dynamiczna tablica w C