Strona główna > C++ > Lista w C (struktury danych)

Lista w C (struktury danych)

//dodawanie, wyswietlanie, szukanie, usuwanie elementow
#include <stdio.h>
typedef struct L
        int key;
        struct L *next;

void show (L *head)
     if(head != NULL){
     while (head != NULL){
           printf("%d ", head->key);
     else printf("No element to show...\n");

void search (L *head, int Find)
     int i=1;
     L *tmp=head;
     while (tmp!= NULL && tmp->key!=Find){
           if (tmp!=NULL){
           printf("Element %d is on %d place ", tmp->key, i);
     else printf("Element does not exist\n");

L *add (L *head, int New)
       L *tmp, *nowy, *cien;
       int tmp2;
       nowy = (L *)malloc(sizeof(L));
       nowy->key = New;

       if (head==NULL){
          else if (head->key >= New){
            while(tmp!=NULL && tmp->key<New){
       return head;

L *Delete (L *head, int Del)

      L *tmp, *tmp2, *pom;
      tmp = head;
          printf("No element to delete...\n");
          return head;
      else if(head->next == NULL && head->key == Del){
           head = NULL;
           return head;
           if (tmp->key== Del){
                   return pom;
               while (tmp2->next!= NULL && tmp2->key != Del){
               if (tmp2->next== NULL){
                     printf("Element does not exist...\n");
               else if(tmp2->next==NULL){  //jesli ostatni
                    tmp->next = NULL;
                    tmp->next = tmp2->next;
                    tmp2 = NULL;

         return head;

int main ()
    int option=0, New, Del, Find;
    L *my_list;
    my_list = ( L *)malloc(sizeof(L));
    my_list = NULL;



               case 1: printf("Type value\n"); scanf("%d",&New);
               my_list=add(my_list,New); break;
               case 2: show(my_list); break;
               case 3: printf("Type value to find\n"); 
                       search(my_list,Find); break;
               case 4: printf("Enter the value to remove\n"); 
                       my_list=Delete(my_list,Del); break;
               case 5: option = 5;break;
               default: break;

    return 0;
  1. 22 czerwca 2013 o 12:30 am

    Woah this website is wonderful i adore researching your content regularly. Maintain the great works of art! You realize, lots of individuals want all-around for this facts, you could make them greatly.

  2. 22 czerwca 2013 o 4:36 am

    I am actually thankful to the owner of this site who has
    shared this wonderful piece of writing at here.

  3. 13 marca 2014 o 6:29 am

    obviously like your web site but you have to test the spelling
    on several of your posts. Many of them are rife with spelling
    issues and I find it very bothersome to tell the reality then again I’ll certainly come back again.

  4. 19 września 2014 o 5:50 am

    Write more, thats aall I have to say. Literally, it seems as though you
    relied on the video to make your point. You clearly know what youre talking about,
    why throw away you intelligence on just posting videos too your blog when you
    could be giving us something informative to read?

  5. 20 września 2014 o 5:34 pm

    I’m gone to convey my little brother, that he should also pay a quick visit this webpage
    on regular basis to get updated from latest information.

  6. 26 września 2014 o 1:21 pm

    Have you ever considered writing an e-book or guest authoring on other
    websites? I have a blog based upon on the same information you discuss and
    would really like to have you share some stories/information. I know
    my viewers would appreciate your work. If you’re even remotely interested, feel
    free to send me an email.

  7. 26 września 2014 o 4:02 pm

    great points altogether, you simply received a emblem
    new reader. What may you recommend in regards to your publish that you simply made a few days in the past?
    Any positive?

  8. 30 października 2014 o 10:29 am

    Your backyard is one of the moost important places and you need to take care of it.
    Almost every Michigan home landscape plan includes
    shrubs but unfortunately whjen you look around a
    new subdivision almost all the homes wiill include the same typpes of shrubs.
    It iss important to chopse plants that you know will flower or give colour all year.

  9. 9 grudnia 2014 o 9:55 pm

    Ahh very interesting. – learn about new
    things every day.

  10. 10 kwietnia 2016 o 4:03 pm

    Thanks for the marvelous posting! I quite enjoyed reading
    it, you’re a great author.I will always bookmark your blog and may come back
    at some point. I want to encourage you to continue your great writing, have a nice weekend!

  11. 14 Maj 2016 o 3:04 am

    It’s very simple to find out any topic on net as compared to books,
    as I found this piece of writing at this web site.

  12. 14 Maj 2016 o 3:31 am

    I couldn’t resist commenting. Perfectly written!

  13. 27 Maj 2016 o 2:10 am

    Hi there would you mind letting me know which hosting company you’re using?

    I’ve loaded your blog in 3 completely different web browsers and I
    must say this blog loads a lot quicker then most. Can you recommend a good web hosting provider at a
    reasonable price? Thanks, I appreciate it!

  14. 4 czerwca 2016 o 1:39 pm

    What’s up friends, its enormous paragraph regarding
    tutoringand fully defined, keep it up all the

  15. 7 czerwca 2016 o 11:40 pm

    Magnificent site. Plenty of helpful information here. I am sending it
    to a few friends ans additionally sharing in delicious.
    And certainly, thanks for your sweat!

  16. 7 czerwca 2016 o 11:41 pm

    Hello mates, nice paragraph and good arguments
    commented here, I am truly enjoying by these.

  17. 10 czerwca 2016 o 1:40 am

    I delight in, result in I found just what I used to be taking a look for.
    You have ended my four day long hunt! God Bless you man. Have a nice day.


  18. 10 czerwca 2016 o 2:13 am

    Hello, I think your site might be having browser compatibility issues.

    When I look at your blog site in Ie, it looks fine but when opening in Internet Explorer, it
    has some overlapping. I just wanted to give you a quick
    heads up! Other then that, awesome blog!

  19. 10 czerwca 2016 o 12:00 pm

    I think this is one of the such a lot important info for me.
    And i am glad reading your article. However want to commentary
    on some basic things, The web site style is perfect, the articles is actually great : D.
    Just right task, cheers

  20. 11 czerwca 2016 o 12:43 am

    Good blog post. I certainly love this site. Continue the good work!

  21. 12 czerwca 2016 o 1:24 pm

    Very good blog you have here but I was curious about if you knew of any discussion boards that
    cover the same topics talked about here?
    I’d really like to be a part of group where I can get feed-back from other knowledgeable individuals that share the same interest.
    If you have any suggestions, please let me know.
    Thank you!

  22. 17 czerwca 2016 o 11:47 pm

    Excellent pieces. Keep posting such kind of info on your site.
    Im really impressed by it.
    Hey there, You have performed a great job.

    I’ll definitely digg it and in my opinion recommend to
    my friends. I am sure they will be benefited from this website.

  23. 21 czerwca 2016 o 2:39 am

    whoah this blog is fantastic i love studying your articles.
    Keep up the good work! You realize, a lot of
    individuals are searching round for this information, you can aid them greatly.

  24. 26 czerwca 2016 o 1:22 am

    wonderful post, very informative. I wonder why
    the opposite experts of this sector do not understand this.
    You must proceed your writing. I am sure, you have a great readers’ base already!

  25. 27 czerwca 2016 o 1:35 am

    excellent points altogether, you simply won a new reader.
    What could you recommend in regards to your publish that
    you simply made some days in the past? Any certain?

  26. 27 czerwca 2016 o 11:53 pm

    Hi there everyone, it’s my first visit at this website,
    and post is truly fruitful in favor of me, keep up posting these types of articles or reviews.

  27. 28 czerwca 2016 o 3:14 pm

    Hi there to all, for the reason that I am in fact keen of reading this webpage’s post to
    be updated daily. It includes pleasant information.

  28. 11 lipca 2016 o 2:06 am

    Hello would you mind letting me know which hosting company you’re
    using? I’ve loaded your blog in 3 different internet browsers and I must say
    this blog loads a lot faster then most. Can you recommend a good web hosting provider at
    a reasonable price? Many thanks, I appreciate it!

  29. 24 sierpnia 2016 o 11:55 am

    certainly like your website however you need to test
    the spelling on several of your posts. A number of them are
    rife with spelling problems and I in finding it very troublesome to tell the reality then again I will
    certainly come again again.

  30. 24 sierpnia 2016 o 5:31 pm

    I don’t even know how I ended up right here, however I assumed
    this submit was good. I do not realize who you’re but definitely you’re going to
    a famous blogger if you aren’t already. Cheers!

  31. 19 sierpnia 2017 o 7:36 pm

    I am no longer certain where you are getting your information, but great topic.
    I must spend a while finding out much more or figuring out more.
    Thanks for great info I was looking for this information for my mission.

  32. 3 listopada 2017 o 8:16 am

    Appreciating the time and energy you put into your blog and detailed information you present.
    It’s awesome to come across a blog every once in a
    while that isn’t the same unwanted rehashed material.
    Fantastic read! I’ve saved your site and I’m adding your RSS feeds to my Google account.

    Tersedia aneka list harga helm terlengkap

  33. 7 grudnia 2017 o 3:19 am

    Hi there, for all time i used to check blog posts here
    early in the daylight, since i like to learn more and more.

  1. 12 października 2014 o 4:37 am
  2. 22 Maj 2016 o 12:57 pm
  3. 17 lipca 2016 o 1:13 pm
  4. 13 sierpnia 2016 o 4:02 am
  5. 13 sierpnia 2016 o 4:23 am
  6. 13 sierpnia 2016 o 5:27 am
  7. 13 sierpnia 2016 o 5:29 am
  8. 30 września 2016 o 2:52 pm
  9. 16 października 2016 o 1:19 pm


Wprowadź swoje dane lub kliknij jedną z tych ikon, aby się zalogować:


Komentujesz korzystając z konta Wyloguj / Zmień )

Zdjęcie z Twittera

Komentujesz korzystając z konta Twitter. Wyloguj / Zmień )

Zdjęcie na Facebooku

Komentujesz korzystając z konta Facebook. Wyloguj / Zmień )

Zdjęcie na Google+

Komentujesz korzystając z konta Google+. Wyloguj / Zmień )

Connecting to %s

%d blogerów lubi to: