Docsity

C Programming Code Snippet, Assignments of Data Structures and Algorithms

Toggle sidebar
bg1
Doda
s4uuetwe
)
Uhita
fhoplvnm
to
fm
plenment
a
fueue
u2.
Tne
ovay.
inclvdtLstA0.h
4#
inelude
L
Con'oh
# decfine
nmox
5
fofnn7,
fronî
= -1,
hur
= 7
Void
Onguene
)
voio
deg
ueue
(),
viel drp
0;
intoin
()
ainE
int
Ch
Pri
t
("
\n1. fnguuu. o
Inket);
h7("nd.
Aqant.
Delete;
h'ndf
\hs.
DRplay")
Phuut
f
wd.
xit)
whih()
phúnt
f(n
Entor
Choica);
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16

Partial preview of the text

Download C Programming Code Snippet and more Assignments Data Structures and Algorithms in PDF only on Docsity!

Doda s4uuetwe

) (^) Uhita fhoplvnm to^ fm^ plenment^ a^ fueue^ u2.Tne

ovay.

inclvdtLstA0.h 4# inelude LCon'oh

decfine^ nmox^5

fofnn7, fronî^ =^ -1,hur^

Void Onguene ) voio deg ueue (), viel drp 0; intoin ()

ainE int Ch Prit ("^ \n1.^ fnguuu.^ o^ Inket); h7("nd.Aqant. Delete; h'ndf \hs. DRplay")

Phuutf wd. xit)

whih()

phúnt (^) f(n Entor (^) Choica);

SCan(d", gch);

StotchCh)

Cnguut0,

Cosc

degu ntC)

CoR dip

Coap A

default: Phientf ("tJhong^ Cloce

Void Ongu tut

PhiedfnDoqua.ud %d',4 fhert) front

Y0d clhp)

if rod= = -T

hitf" n ueu it En-py)

hd f(" Elenm0ent%..") foniront i A. Exit Crctoh chora

vdth choice:

Unepfbw &t chojce;

Ext Flmnnt: 1o

EelEnt Choice 20 EntDh Clhoice, Zo WrOng dhoice Cntchoie &nt Eemnt.So

Ene lmut 4d

Wut A^ pro iom^ to^ implomnt^ a^ guuto^ tuing

n t tubing inKdle

#inclulu Zstolio.h #Ineluele Lstdlb.h Stuef node

int infe Sthuuct nocde "pth; pent. raey, tomp, front 1,

nt frontolemeut()

void (^) cng (^) int (^) deta); Vejd dog ()0; VDiol ompty

yDicl (^) queut (^) BZ.) ; t Count D

Void maint)

fut (^) no, th, (^2)

Rtntf '1 -nque") Pheintf("h2- Doque") Phtntf(n^ - fruont^ olomout") Print ("A-Pnpfy) fA144 5 Exit frint f^ (Lnt^

  • Diphy ),

l'1tf1n? - Suatue^ B/ze);

Ctete )

fintf(nEntth Choite ")

Stan f (/d", Sch) Switch (th)

Phntf ('ntPi^ drta:"); Carnf "/hd^ R^ no);

ng no)

do )

0 t Void Cate )

fiont : 2ten NULL;

Rettwn 4Ue te 3/ ze yeicl Guukize l)

Ptf ("1h Btesa. Biz0 dCout

hgluinq th Void (^) cng (iht^ deta)

1ncah== NOLL)

u (ut^ nodemalloc(7^ 8izL^ f/84aende uh-pth NULl; tre-5info dota front rla

G pt 7emp oelo

Onp->info dada

.

tCn ptn NDLZ;

Cound 4+

/Dixploying^ the^ guuw.^ olemonti/ id dplaye)

frort I = {rOnd ;

if (frout^ 7:=NOLL^ )RE^

(aa =a^ NUDL))

intfBwu, tz opty'); tun

ohile (fiont^ I^ l^ =eah)

pntfl, feont ->infe);

d Aront 1-Ppt;

vdf (d, fund1>inft

/frtos the nt fontelome t t)

e nt!^ NOLL^ J&L^ (reah^ I=NOLL) cton (Pout-infb) olic

Displry if Gtet L enpty oh net/

70oid Cnytyl

i (^) Cfont:: (^) NULL. (^) )2& (^) (20as (^) NGLL))

fpirtf (n ueueempfy

intfeut. nof oty

Ot fut

-ng 2- Pegu

A - Smpty

xif

-9play -BtUo tR 3ize rt 7 Clhof^ ce^1

rt clata 'g Choice

E1dn hoict ftert eleaond 4 nd th clh: et 14 35 8

nd Bchoicc

ta phoflamto^ implon0ed^ a^ citernla

1 inelucle 21dfoh>)

del inc. it quetucex_7,^ /day^

d-loshotitn intfiont =-1; ntee-1, funcfion to^ in&0f*^ an^

olenent tna Cincrdet gtueuce Vicngteeu.(int olemet)

lfrenteE -]KE^ Pugm^ =^ -T)/}^ coreditidey

to chehalheu

'elBc if (itoh 1) /-*1exe front)/ tcrdhion to ehich Glus u fl

tutf Bue.^ i^ vve^ flouw-"

ren=2t t1)/^ rmo^ /an^18

inchmtitod

quo un]^ olemenl,^ 1/ersigniing^

a nliu^ to

PokIfOn

funct io^ to^ dolett^ fho^ olennent^ roy

ilftord=-3)k-[tuR=1)// torel its

t checiGueue

PtPty

.

Vnid diyloy

int f:frev 1(fronf -:-1 KL ktah --1)

Pintf Bous t8^ arpty

intf C"h Eleneti a Buta ve:); ybile (ic-ro)

i:(i+1)/ max

int moin)

int Clict. 1, X; //a iadkes clela nttiy

ftindfn fnsh^ nbot^ an^ elemont^ V

Prdfn fon^ :0nphy^

ta slimtnt;

fintf('In^ Ente^ you,^

cloia (^) ")

S d",^ &^ choici); wtch Choice)

fPuintf ('Entoh^ the^ olemnt^ toh^

to

onf :hd"Rr); ung upus. x);