#ifndef QUEUE_H
#define QUEUE_H
#include <string>
#include <iostream>
class Hikkey{
private :
std:: string name;
public :
virtual void fuck( ) = 0 ;
} ;
class AttentionWhore : public Hikkey{
private :
std:: string name;
public :
AttentionWhore( std:: string pogonyalo) { name = pogonyalo; }
virtual void fuck( ) {
std:: cout << name << " vieban i obossan" << std:: endl ;
}
void porvatsya( ) { std:: cout << name << " porvalsya" << std:: endl ; }
} ;
template < class T>
class NodeQueue
{
public :
NodeQueue( ) : head( 0 ) , tail( 0 ) { }
~NodeQueue( )
{
while ( head)
{
tail= head- > next;
delete head;
head= tail;
}
}
void enqueue( T val)
{
Node* Temp= new Node;
Temp- > elem= val;
if ( head== 0 )
{
head= Temp;
tail= Temp;
return ;
}
tail- > next= Temp;
tail= Temp;
}
void nahooy( )
{
if ( empty( ) )
{
throw std:: string ( "Queue is empty" ) ;
}
Node* delPtr= head;
head= head- > next;
delete delPtr;
}
const T& front( ) const
{
if ( empty( ) )
{
throw std:: string ( "Queue is empty" ) ;
}
return head- > elem;
}
void print( ) const
{
if ( empty( ) )
{
throw std:: string ( "Queue is empty" ) ;
}
for ( Node* ptr= head; ptr! = 0 ; ptr= ptr- > next)
std:: cout << ptr- > elem<< ' ' ;
std:: cout << '\n ' ;
}
bool empty( ) const
{
return head== 0 ;
}
private :
struct Node
{
Node( ) : next( 0 ) , elem( 0 )
{
}
Node* next;
T elem;
} ;
Node* head;
Node* tail;
} ;
#endif // QUEUE_H
int main( )
{
std:: string whores[ ] = { "Madina" , "Ponos" , "Yakooy" , "ID25" , "Kotomi" , "Smith" , "Console" , "Rugged" , "Ba4mo" , "Tolyan" , "Elsa" , "Stoocka" , "Chaos" , "Barebuh" , "Sento" } ;
NodeQueue< AttentionWhore* > mrazy;
for ( int i = 0 ; i < 15 ; i++ )
mrazy.enqueue ( new AttentionWhore( whores[ i] ) ) ;
for ( int i = 0 ; i < 15 ; i++ ) {
mrazy.front ( ) - > fuck( ) ;
mrazy.front ( ) - > porvatsya( ) ;
m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gICAgICAgTm9kZSogVGVtcD1uZXcgTm9kZTsKICAgICAgICAgICAgICAgIFRlbXAtPmVsZW09dmFsOwogICAgICAgICAgICAgICAgaWYoaGVhZD09MCkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgaGVhZD1UZW1wOwogICAgICAgICAgICAgICAgICAgICAgICB0YWlsPVRlbXA7CiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIHRhaWwtPm5leHQ9VGVtcDsKICAgICAgICAgICAgICAgIHRhaWw9VGVtcDsKICAgICAgICB9CgogICAgICAgIHZvaWQgbmFob295KCkKICAgICAgICB7CiAgICAgICAgICAgICAgICBpZiAoZW1wdHkoKSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgc3RkOjpzdHJpbmcoIlF1ZXVlIGlzIGVtcHR5Iik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBOb2RlKiBkZWxQdHI9aGVhZDsKICAgICAgICAgICAgICAgIGhlYWQ9aGVhZC0+bmV4dDsKICAgICAgICAgICAgICAgIGRlbGV0ZSBkZWxQdHI7CiAgICAgICAgfQoKICAgICAgICBjb25zdCBUJiBmcm9udCgpIGNvbnN0CiAgICAgICAgewogICAgICAgICAgICAgICAgaWYgKGVtcHR5KCkpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IHN0ZDo6c3RyaW5nKCJRdWV1ZSBpcyBlbXB0eSIpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgcmV0dXJuIGhlYWQtPmVsZW07CiAgICAgICAgfQoKICAgICAgICB2b2lkIHByaW50KCkgY29uc3QKICAgICAgICB7CiAgICAgICAgICAgICAgICBpZiAoZW1wdHkoKSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgc3RkOjpzdHJpbmcoIlF1ZXVlIGlzIGVtcHR5Iik7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBmb3IoTm9kZSogcHRyPWhlYWQ7IHB0ciE9MDsgcHRyPXB0ci0+bmV4dCkKICAgICAgICAgICAgICAgICAgICAgICAgc3RkOjpjb3V0PDxwdHItPmVsZW08PCcgJzsKICAgICAgICAgICAgICAgIHN0ZDo6Y291dDw8J1xuJzsKICAgICAgICB9CgogICAgICAgIGJvb2wgZW1wdHkoKSBjb25zdAogICAgICAgIHsKICAgICAgICAgICAgICAgIHJldHVybiBoZWFkPT0wOwogICAgICAgIH0KcHJpdmF0ZToKICAgICAgICBzdHJ1Y3QgTm9kZQogICAgICAgIHsKICAgICAgICAgICAgICAgIE5vZGUoKTpuZXh0KDApLCBlbGVtKDApCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICBOb2RlKiBuZXh0OwogICAgICAgICAgICAgICAgVCBlbGVtOwogICAgICAgIH07CiAgICAgICAgTm9kZSogaGVhZDsKICAgICAgICBOb2RlKiB0YWlsOwp9OwoKI2VuZGlmIC8vIFFVRVVFX0gKCmludCBtYWluKCkKewoKICAgIHN0ZDo6c3RyaW5nIHdob3Jlc1tdID0geyJNYWRpbmEiLCAiUG9ub3MiLCAiWWFrb295IiwgIklEMjUiLCAiS290b21pIiwgIlNtaXRoIiwgIkNvbnNvbGUiLCAiUnVnZ2VkIiwgIkJhNG1vIiwgIlRvbHlhbiIsICJFbHNhIiwgIlN0b29ja2EiLCAiQ2hhb3MiLCAiQmFyZWJ1aCIsICJTZW50byJ9OwogICAgTm9kZVF1ZXVlPEF0dGVudGlvbldob3JlKj4gbXJhenk7CgogICAgZm9yKGludCBpID0gMDsgaSA8IDE1OyBpKyspCiAgICAgICAgbXJhenkuZW5xdWV1ZShuZXcgQXR0ZW50aW9uV2hvcmUod2hvcmVzW2ldKSk7CiAgICBmb3IoaW50IGkgPSAwOyBpIDwgMTU7IGkrKyl7CiAgICAgICAgbXJhenkuZnJvbnQoKS0+ZnVjaygpOwogICAgICAgIG1yYXp5LmZyb250KCktPnBvcnZhdHN5YSgpOwogICAgICAgIG1yYXp5Lm5haG9veSgpOwogICAgICAgIHN0ZDo6Y291dCA8PCBzdGQ6OmVuZGw7CiAgICB9CiAgICByZXR1cm4gMDsKfQ==