Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://vk.com/evgenykravchenko0
- ___ ___ ___
- / /\ ___ / /\ / /\
- / /:/_ /__/\ / /:/_ / /:/_
- / /:/ /\ \ \:\ / /:/ /\ / /:/ /\
- / /:/ /:/_ \ \:\ / /:/_/::\ / /:/ /:/_
- /__/:/ /:/ /\ ___ \__\:\ /__/:/__\/\:\ /__/:/ /:/ /\
- \ \:\/:/ /:/ /__/\ | |:| \ \:\ /~~/:/ \ \:\/:/ /:/
- \ \::/ /:/ \ \:\| |:| \ \:\ /:/ \ \::/ /:/
- \ \:\/:/ \ \:\__|:| \ \:\/:/ \ \:\/:/
- \ \::/ \__\::::/ \ \::/ \ \::/
- \__\/ ~~~~ \__\/ \__\/
- ___
- /__/\ ___ ___
- \ \:\ / /\ / /\
- \ \:\ / /:/ / /:/
- _____\__\:\ /__/::\ /__/::\
- /__/::::::::\ \__\/\:\__ \__\/\:\__
- \ \:\~~\~~\/ \ \:\/\ \ \:\/\
- \ \:\ ~~~ \__\::/ \__\::/
- \ \:\ /__/:/ /__/:/
- \ \:\ \__\/ \__\/
- \__\/
- #include <stdio.h>
- #include <stdlib.h>
- #include <locale.h>
- #include "list.h"
- int main(int argc, char *argv[])
- {
- size_t i;
- int val;
- List *lst, *lstCopy;
- setlocale(LC_ALL, "Russian");
- printf("—ÓÁ‰‡∏Ï ÔÛÒÚÓÈ ÒÔËÒÓÍ:\n");
- lst = Create();
- PrintList(lst);
- printf("\nƒÓ·‡‚ÎeÌË ˝ÎÂÏÂÌÚÓ‚ ‚ ÍÓ̈ ÒÔËÒ͇:\n");
- for (i = 0; i < 10; i ++)
- Append(lst, i);
- PrintList(lst);
- printf("\nœÓÎÌÓ ÍÓÔËÓ‚‡ÌË ÒÔËÒ͇:\n");
- lstCopy = Copy(lst);
- PrintList(lstCopy);
- printf("\nƒÓ·‡‚ÎeÌË ˝ÎÂÏÂÌÚÓ‚ ‚ ̇˜‡ÎÓ ÒÔËÒ͇:\n");
- for (i = 10; i < 20; i ++)
- Prepend(lstCopy, i);
- PrintList(lstCopy);
- printf("\n¬ÒÚ‡‚͇ ‚ÒÂı ˝ÎÂÏÂÌÚÓ‚ Ó‰ÌÓ„Ó ÒÔËÒ͇ ‚ ÍÓ̈ ‰Û„Ó„Ó:\n");
- AppendAll(lstCopy, lst);
- PrintList(lstCopy);
- // ÒÓÁ‰‡∏Ï ÂÁ‚ÌÛ˛ ÍÓÔ˲ ‰Îˇ ‰‡Î¸ÌÂȯËı ÚÂÒÚÓ‚
- lstCopy = Copy(lst);
- printf("\n¬ÒÚ‡‚͇ ˝ÎÂÏÂÌÚ‡ ÔÓ Ë̉ÂÍÒÛ:\n");
- printf("¬ÒÚ‡‚͇ ‚ ÌÛÎÂ‚Û˛ ÔÓÁËˆË˛:\n");
- InsertAt(lst, 99, 0);
- PrintList(lst);
- printf("¬ÒÚ‡‚͇ ‚ ÔÓÒÎÂ‰Ì˛˛ ÔÓÁËˆË˛:\n");
- InsertAt(lst, 100, 10);
- PrintList(lst);
- printf("¬ÒÚ‡‚͇ ‚ ÔÓÁËˆË˛ Á‡ ÔÓÒΉÌËÏ ˝ÎÂÏÂÌÚÓÏ:\n");
- InsertAt(lst, 101, 15);
- PrintList(lst);
- // ‚ÓÒÒڇ̇‚ÎË‚‡ÂÏ ÒÔËÒÓÍ ËÁ ÂÁ‚ÌÓÈ ÍÓÔËË
- lst = Copy(lstCopy);
- printf("\n”‰‡ÎÂÌË ˝ÎÂÏÂÌÚ‡ ÔÓ Ë̉ÂÍÒÛ:\n");
- printf("»ÒıÓ‰Ì˚È ÒÔËÒÓÍ:\n");
- PrintList(lst);
- printf("”‰‡ÎÂÌË ËÁ ÌÛ΂ÓÈ ÔÓÁˈËË:\n");
- RemoveAt(lst, 0);
- PrintList(lst);
- printf("”‰‡ÎÂÌË ËÁ ÔÓÒΉÌÂÈ ÔÓÁˈËË:\n");
- RemoveAt(lst, 8);
- PrintList(lst);
- printf("”‰‡ÎÂÌË ËÁ ÔÓÁˈËË Á‡ ÔÓÒΉÌËÏ ˝ÎÂÏÂÌÚÓÏ:\n");
- RemoveAt(lst, 8);
- PrintList(lst);
- printf("\n”‰‡ÎÂÌË ‚ÒÂı ˝ÎÂÏÂÌÚÓ‚ ËÁ ÒÔËÒ͇:\n");
- RemoveAll(lst);
- PrintList(lst);
- // ‚ÓÒÒڇ̇‚ÎË‚‡ÂÏ ÒÔËÒÓÍ ËÁ ÂÁ‚ÌÓÈ ÍÓÔËË
- lst = Copy(lstCopy);
- printf("\n”‰‡ÎÂÌË ˝ÎÂÏÂÌÚ‡ Ò ÍÓ̈‡ ÒÔËÒ͇, ÙÛÌÍˆËˇ ‚ÓÁ‚‡˘‡ÂÚ Û‰‡ÎÂÌÌ˚È ˝ÎÂÏÂÌÚ:\n");
- printf("»ÒıÓ‰Ì˚È ÒÔËÒÓÍ:\n");
- PrintList(lst);
- for (i = 0; i < 10; i ++)
- {
- val = Pop(lst);
- printf("›ÎÂÏÂÌÚ: %d, —ÔËÒÓÍ: ", val);
- PrintList(lst);
- }
- // ‚ÓÒÒڇ̇‚ÎË‚‡ÂÏ ÒÔËÒÓÍ ËÁ ÂÁ‚ÌÓÈ ÍÓÔËË
- lst = Copy(lstCopy);
- printf("\n”‰‡ÎÂÌË ˝ÎÂÏÂÌÚ‡ Ò Ì‡˜‡Î‡ ÒÔËÒ͇, ÙÛÌÍˆËˇ ‚ÓÁ‚‡˘‡ÂÚ Û‰‡ÎÂÌÌ˚È ˝ÎÂÏÂÌÚ:\n");
- printf("»ÒıÓ‰Ì˚È ÒÔËÒÓÍ: ");
- PrintList(lst);
- for (i = 0; i < 10; i ++)
- {
- val = Dequeue(lst);
- printf("›ÎÂÏÂÌÚ: %d, —ÔËÒÓÍ: ", val);
- PrintList(lst);
- }
- // ‚ÓÒÒڇ̇‚ÎË‚‡ÂÏ ÒÔËÒÓÍ ËÁ ÂÁ‚ÌÓÈ ÍÓÔËË
- lst = Copy(lstCopy);
- printf("\n¬˚˜ËÒÎÂÌË ‰ÎËÌ˚ ÒÔËÒ͇:\n");
- printf("»ÒıÓ‰Ì˚È ÒÔËÒÓÍ: ");
- PrintList(lst);
- printf("ƒÎË̇: %d\n", Length(lst));
- printf("Œ˜Ë˘‡ÂÏ ÒÔËÒÓÍ: ");
- RemoveAll(lst);
- PrintList(lst);
- printf("ƒÎË̇: %d\n", Length(lst));
- // ‚ÓÒÒڇ̇‚ÎË‚‡ÂÏ ÒÔËÒÓÍ ËÁ ÂÁ‚ÌÓÈ ÍÓÔËË
- lst = Copy(lstCopy);
- printf("\n¬ÁˇÚË ˝ÎÂÏÂÌÚ‡ ÒÔËÒ͇ ÔÓ Ë̉ÂÍÒÛ:\n");
- printf("»ÒıÓ‰Ì˚È ÒÔËÒÓÍ: ");
- PrintList(lst);
- for (i = 0; i < 10; i ++)
- printf("›ÎÂÏÂÌÚ π%d = %d\n", i, GetAt(lst, i));
- RemoveAll(lst);
- RemoveAll(lstCopy);
- printf("\n");
- system("Pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement