Strona główna
> Stos > Stos
Stos
#include<iostream> #include<conio.h> using namespace std; template <class T> struct node { node* prev; T val; }; template <class T> class Stack { public: node<T> *top; Stack(); Stack(const Stack& A); ~Stack(); void Push(T a); T Pop(); void Show(); Stack<T>& operator+(T const & A); }; template <class T> Stack<T>::Stack() { cout<<"Konstruktor\n"; top=NULL; } template <class T> Stack<T>::Stack(const Stack& A) { cout<<"\nCopy:\n"; top=NULL; node<T>* wsk=A.top; while(wsk) { this->Push(wsk->val); wsk=wsk->prev; } } template <class T> Stack<T>::~Stack() { cout<<"Destruktor\n"; node<T> *wsk=top; node<T> *tmp; while(wsk) { tmp=wsk->prev; delete wsk; wsk=tmp; } } template <class T> void Stack<T>::Push(T a) { node<T>* nowy=new node<T>; nowy->val=a; nowy->prev=NULL; if(!top) top=nowy; else { node<T>* wsk=top; while(wsk->prev) { wsk=wsk->prev; } nowy->prev=top; top=nowy; } } template <class T> Stack<T>& Stack<T>::operator+(T const & A) { this->Push(A); } template <class T> T Stack<T>::Pop() { node<T> *wsk=top; T tmp; if(!top) cout<<"Stos pusty\n"; else { top=top->prev; tmp=wsk->val; delete wsk; } return tmp; } template <class T> void Stack<T>::Show() { node<T>* wsk=top; if(!top) cout<<"Pusto...\n"; else { cout<<"Na Stosie: \n"; while(wsk) { cout<<wsk->val<<"\n"; wsk=wsk->prev; } } } int main() { Stack<char> A; A.Push('a'); A.Push('b'); A.Push('c'); A.Show(); Stack<float> B; B.Push(5.5); B.Push(3.3); B.Push(4.4); B.Show(); cout<<"\nUsuwam ze Stosu: "<<B.Pop()<<endl; cout<<"\n"; B.Show(); Stack<char> C(A); C+('X'); C.Show(); getch(); return 0; }
Kategorie:Stos
When I originally left a comment I appear to have clicked the -Notify me when new comments are
added- checkbox and from now on each time a comment is added I
receive four emails with the exact same comment.
Is there a way you are able to remove me from that service?
Thank you!
You aren’t a follower of this blog, and from that account it’s your first comment, so I am don’t think you have that problem. If it’s true plz comment one more time, after that I’ll try to change options, but now I am don’t really sure that your coment isn’t only a spam, that aksimet don’t block. I’ll wait for a week, If you don’t say something I’ll delete yours comment.
Have you ever thought about including a little bit more than just your articles?
I mean, what you say is valuable and everything. But imagine if you added some great photos or videos to give
your posts more, „pop”! Your content is excellent but
with pics and videos, this blog could definitely be
one of the best in its field. Amazing blog!
This information is worth everyone’s attention. Where can I find
out more?
Heya i’m for the first time here. I came across this board and I in finding
It really useful & it helped me out much. I’m hoping to give one thing back and help others
such as you helped me.
I am really impressed with your writing talents and also with the layout on your blog.
Is this a paid subject matter or did you customize
it your self? Either way stay up the nice high quaality writing, iit is uncommon to look a nice blog like this one
nowadays..
I always used to study post in news papers but now as I
am a user of web therefore from now I am using net for content, thanks to web.
Thanks for finally wrriting about >Stoss | Czas na zeszyt…xD <Liked it!
Thanks for sharing your thoughts on winload.exe malware.
Regards
It’s an awesome piece of writing for all the internet viewers; they will get benefit from it I am sure.
You really make it seem really easy along with your presentation but
I in finding this matter to be actually something that
I believe I would never understand. It sort of feels too
complex and very vast for me. I’m looking ahead to your next publish, I’ll attempt to get the hold of it!
Hello to every one, for the reason that I am actually eager
of reading this blog’s post to be updated regularly. It consists of good data.
Excellent website you have here but I was curious if you knew of any user discussion forums that
cover the same topics discussed in this article?
I’d really like to be a part of online community where
I can get opinions from other experienced individuals
that share the same interest. If you have any recommendations, please
let me know. Bless you!
WOW just what I was looking for. Came here by searching for usp10.dll crash
Link exchange is nothing else but it is just placing the other person’s weblog link
on your page at proper place and other person will also do similar
for you.
I’m really enjoying the design and layout of your website.
It’s a very easy on the eyes which makes it much more enjoyable for me to come here and visit more often.
Did you hire out a developer to create your theme? Exceptional work!
I got this web site from my pal who informed me about this web page and at
the moment this time I am browsing this web page and reading very informative posts at this place.
Hi everyone, it’s my first visit at this web page, and post is
actually fruitful for me, keep up posting these types of articles or reviews.
We are a gaggle of volunteers and opening a new scheme in our community.
Your site offered us with helpful information to work on. You’ve
done a formidable process and our whole neighborhood shall be grateful to you.
Excellent blog! Do you have any suggestions for aspiring writers?
I’m planning to start my own site soon but I’m a little lost on everything.
Would you propose starting with a free platform like WordPress or go
for a paid option? There are so many options out there that I’m completely confused ..
Any tips? Kudos!
This is my first time pay a quick visit at here and i am genuinely impressed to read all at one
place.
With havin so much content and articles do you ever run into
any problems of plagorism or copyright violation? My blog has a lot of unique
content I’ve either written myself or outsourced but it appears
a lot of it is popping it up all over the web without my agreement.
Do you know any methods to help stop content from being stolen? I’d certainly appreciate it.
Do you mind if I quote a couple of your articles as long as I provide
credit and sources back to your weblog? My
blog site is in the exact same niche as yours and my visitors would definitely benefit from some of the information you provide here.
Please let me know if this okay with you. Thanks a lot!
Hi, I wish for to subscribe for this webpage to take most recent updates, therefore where can i do it
please assist.
Thank you for the auspicious writeup. It in truth was a enjoyment account it.
Glance complicated to more added agreeable from you!
However, how can we keep up a correspondence?
If you are going for best contents like me, just go to see this web page every day as it presents feature contents, thanks
Thanks to my father who stated to me on the topic of this weblog, this website is actually amazing.
Wow, that’s wat I waas exploring for, what a information! existing here at
thhis weblog, thanks admin of this webb page.
Hey 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 quicker then most. Can you recommend a good hosting provider
at a honest price? Many thanks, I appreciate it!
I just like the helpful information you provide for your articles.
I will bookmark your blog and take a look at once more right here regularly.
I’m relatively sure I’ll learn plenty of new stuff proper right here!
Best of luck for the next!
Everyone loves it when folks come together and share views.
Greawt site, tick with it!
Magnificent website. Lots of helpful info
here. I’m sending it to a few buddies ans additionally sharing in delicious.
And certainly, thank you in your sweat!