Sie sind auf Seite 1von 23

S.NO CONTENT PG.

NO
1. SORTING OF ARRAYS
2. STUDENT DETAILS
3. PALINDROME
4. STACK OPERATION
5. QUEUE OPERATION
6. SIMPLE VALIDATION IN JAVASCRIPT
7. VALIDATION CONTROL IN ASP.NET
8. EMAIL VALIDATION IN JAVASCRIPT
. PROCESS TESTING ! FILE UPLOAD IN C" SCRIPT
1#.
FUNCTIONAL TESTING! DATA$ASE CONNECTION IN ASP.NET %
V$ SCRIPT
VALIDATION CONTROL IN ASP.NET
&TML CODE !
<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1/xhtml" >
<hea! runat="ser"er">
<t#tle> $%L&'%(&)* </t#tle>
</hea!>
<+o!,>
<-orm #!="-orm1" runat="ser"er">
<!#">
<h. st,le="/olor:0e!">$al#!at#on</h.>
<ta+le w#!th="12%">
<tr>
<t! /olspan=".">
<asp:$al#!at#on3ummar, &'="$al#!at#on3ummar,1" runat="ser"er"
4ea!er(ext="5ollow#ng error o//urs:" 3how6essage7ox="-alse"
'#spla,6o!e="7ulletL#st" 3how3ummar,="true" 8#!th=".29px" />
</t!>
</tr>
<tr>
<t! /olspan="."><asp:La+el &'="La+el." runat="ser"er" (ext=""
></asp:La+el></t!>
</tr>
<tr>
<t!><asp:La+el &'="La+el1" runat="ser"er" (ext=":ma#l" ></asp:La+el></t!>
<t!>
<asp:(ext7ox &'="(ext7ox1" runat="ser"er" %utoPost7a/;="true"
)n(extChange!="(ext7ox1<(extChange!" ></asp:(ext7ox>
<asp:0e=u#re!5#el!$al#!ator &'="0e=u#re!5#el!$al#!ator1" runat="ser"er"
Control(o$al#!ate="(ext7ox1" :rror6essage="Please 5#ll the ema#l>
3et5o/us)n:rror="true" (ext="?"></asp:0e=u#re!5#el!$al#!ator>
</t!>
</tr>
<tr>
<t! /olspan="."><asp:7utton &'="7utton1" runat="ser"er" (ext="3u+m#t"
)nCl#/;="7utton1<Cl#/;" /></t!>
</tr>
</ta+le>
</!#">
</-orm>
</+o!,>
</html>
C" CODE !
pu+l#/ part#al /lass 'e-ault. : 3,stem.8e+.@&.Page
A
prote/te! "o#! 7utton1<Cl#/;Bo+Ce/t sen!erD :"ent%rgs eE
A
La+el..(ext = "Four 6a#l &' #s : " G (ext7ox1.(ext.(o3tr#ngBEH
I
I
OUTPUT!
SIMPLE VALIDATION IN JAVASCRIPT
&TML CODE !
<-orm name="-rmConta/t@s" #!="-rmConta/t@s">
<ta+le w#!th="122%" +or!er="2" al#gn="/enter">
<tr>
<t! "al#gn="top" w#!th="31%">?<strong>*ame : </strong></t!>
<t! "al#gn="top">
<#nput name="txt:ma#l*ame" t,pe="text" #!="txt:ma#l*ame"/>
</t!>
</tr>
<tr>
<t! "al#gn="top" w#!th="31%">?<strong>:ma#l : </strong></t!>
<t! "al#gn="top">
<#nput name="txt:ma#l5rom" t,pe="text" #!="txt:ma#l5rom"/>
</t!>
</tr>
<tr>
<t! "al#gn="top">?<strong>6essage: </strong></t!>
<t! "al#gn="top">
<textarea name="txt:ma#l6essage" #!="txt:ma#l6essage"></textarea></t!>
</tr>
<tr>
<t!>Jn+spH</t!>
<t! al#gn="le-t">
<#nput /lass="+uttonClass" on/l#/;="return "al#!ate5ee!s5ormBE" "alue="3en!
6a#l" t,pe="+utton">
<#nput /lass="+uttonClass" "alue="Can/el" t,pe="+utton">
</t!>
</tr>
</ta+le>
</-orm>
K%$%3C0&P( :
<s/r#pt>
-un/t#on"al#!ate5ee!s5ormBE A
"ar-/tn6a#l*ame = !o/ument.get:lement7,&!BLtxt:ma#l*ameLE."alueH
"ar-/tn6a#l6essage = !o/ument.get:lement7,&!BLtxt:ma#l6essageLE."alueH
"ar-/tn6a#l5rom = !o/ument.get:lement7,&!BLtxt:ma#l5romLE."alueH
#- B-/tn6a#l*ame == ""E A
alertB"Please enter the *ame"EH
!o/ument.get:lement7,&!BLtxt:ma#l*ameLE.-o/usBEH
return -alseH
I
#- B-/tn6a#l5rom == ""E A
alertB"Please enter the :ma#l a!!ress"EH
!o/ument.get:lement7,&!BLtxt:ma#l5romLE.-o/usBEH
return -alseH
I
#- B-/tn6a#l6essage == ""E A
alertB"Please enter the message"EH
!o/ument.get:lement7,&!BLtxt:ma#l6essageLE.-o/usBEH
return -alseH
I
!o/ument.-rmConta/t@s.su+m#tBEH
return trueH
I
</s/r#pt>
OUTPUT !
EMAIL VALIDATION IN JAVASCRIPT
&TML CODE !
<-orm name="-rmConta/t@s" #!="-rmConta/t@s">
<ta+le w#!th="122%" +or!er="2" al#gn="/enter">
<tr>
<t! "al#gn="top" w#!th="31%"><sup /lass="aster#s;">?</sup><strong>:ma#l :
</strong></t!>
<t! "al#gn="top"><#nput name="txt:ma#l" t,pe="text" /lass="-rm(ext+ox"
#!="txt:ma#l"/></t!>
</tr>
<tr>
<t!>Jn+spH</t!>
<t! al#gn="le-t">Jn+spH</t!>
</tr>
<tr>
<t!>Jn+spH</t!>
<t! al#gn="le-t"><#nput /lass="+uttonClass" on/l#/;="return "al#!ate5ormBE"
"alue="$al#!ate" t,pe="+utton">
<#nput /lass="+uttonClass" "alue="Can/el" t,pe="+utton"></t!>
</tr>
</ta+le>
</-orm>
JAVASCRIPT !
<s/r#pt>
-un/t#on"al#!ate:ma#lBarg:ma#lE A
"arema#l0eg:x = /MBNaOP%OQ2O<R.ROSEGR@BBNaOP%OQ2OROSEGR.EGBNaOP%OQ2OSA.DTIE
GU/H
#- Barg:ma#l.mat/hBema#l0eg:xEE A
return true
I else A
return -alseH
I
I
-un/t#on"al#!ate5ormBE A
"ar-/tn6a#l5rom = !o/ument.get:lement7,&!BLtxt:ma#lLE."alueH
#- B-/tn6a#l5rom == ""E A
alertB"Please enter the :ma#l a!!ress"EH
!o/ument.get:lement7,&!BLtxt:ma#lLE.-o/usBEH
return -alseH
I
#- B-/tn6a#l5rom V= ""E A
#- BV"al#!ate:ma#lB-/tn6a#l5romEE A
alertB"Please enter a "al#! :ma#l a!!ress"EH
!o/ument.get:lement7,&!BLtxt:ma#lLE.-o/usBEH
return -alseH
I
I
!o/ument.-rmConta/t@s.su+m#tBEH
return trueH
I
</s/r#pt>
OUTPUT !
PROCESS TESTING! FILE UPLOAD IN C" SCRIPT.
&TML CODE !
<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1/xhtml" >
<hea! runat="ser"er"><t#tle>@PL)%' 5&L: </t#tle></hea!>
<+o!,>
<-orm #!="-orm1" runat="ser"er">
<h.>@ploa! 5#le</h.>
<asp:La+el &'="La+el1" runat="ser"er" 5ontO3#Pe="Large"
5oreColor="Corn-lower7lue"></asp:La+el>
<+r /><+r />
<asp:5#le@ploa! &'="5#le@ploa!1" runat="ser"er" />
<asp:7utton &'="7utton1" runat="ser"er" (ext="@ploa! th#s 5#le"
)nCl#/;="7utton1<Cl#/;" />
</-orm>
</+o!,>
</html>
C# C)': :
us#ng 3,stem.&)H
pu+l#/ part#al /lass 'e-ault. : 3,stem.8e+.@&.Page
A
prote/te! "o#! 7utton1<Cl#/;Bo+Ce/t sen!erD :"ent%rgs eE
A
#- B5#le@ploa!1.4as5#leE
A
tr,A
str#ng appPath = 0e=uest.Ph,s#/al%ppl#/at#onPathH
str#ng -#lePath = appPath G "@ploa!RR"H
str#ng extens#on =
Path.Wet:xtens#onB5#le@ploa!1.Poste!5#le.5#le*ameEH
5#le@ploa!1.3a"e%sB-#lePath G "6, 5#lename" G extens#onEH
La+el1.(ext = "@ploa!e! 5#le Path: " G
5#le@ploa!1.Poste!5#le.5#le*ameH
La+el1.(ext G= "<+r />5#le *ame: " G 5#le@ploa!1.5#le*ameH
La+el1.(ext G= "<+r />5#le 3#Pe: " G
5#le@ploa!1.Poste!5#le.ContentLengthH
La+el1.(ext G= "<+r />5#le (,pe: " G
5#le@ploa!1.Poste!5#le.Content(,peH
La+el1.(ext G= "<+r />5#le :xtens#on: " G extens#onH I
/at/h B:x/ept#on exEA
La+el1.(ext = ":rror o//ure!: " G ex.6essage.(o3tr#ngBEH
I
IelseA
La+el1.(ext = "3ele/t a -#le -or uploa!"H
I
I
I
OUTPUT!
FUNCTIONAL TESTING! DATA$ASE CONNECTION IN ASP.NET % V$ SCRIPT
V$ CODE !
&mports 3,stem.'ata.3=lCl#ent
&mports 3,stem.'ata
Part#al Class <'e-ault
&nher#ts 3,stem.8e+.@&.Page
'#m /n %s *ew 3=lConne/t#on
'#m s!a %s *ew 3=l'ata%!apter
'#m /m! %s *ew 3=lComman!
'#m str %s 3tr#ng
'#m !s %s *ew 'ata3et
3u+ /onne/tBE
(r,
str = "&ntegrate! 3e/ur#t,=33P&HPers#st 3e/ur#t,
&n-o=5alseH&n#t#al Catalog=masterH'ata 3our/e=."
/n = *ew 3=lConne/t#onBstrE
/n.)penBE
0esponse.8r#teBXConnne/te!>E
Cat/h ex %s :x/ept#on
0esponse.8r#teBex.6essage.(o3tr#ngBEE
:n! (r,
:n! 3u+
Prote/te! "o#! Page<Loa!BE A
/onne/tBE
I
:n! Class
OUTPUT!
&- /onne/te! to !ata+ase C)**:C(:' w#ll +e !#spla,e! else 3F3(:6 8&(4 (40)8 %
:YC:P(&)* message relate! to the esta+l#shment -or the !ata+ase
SORTING OF ARRAYS
##n/lu!e<st!#o.h>
##n/lu!e</on#o.h>
"o#! ma#nBE
A
#nt l#st1N.2SDl#st.N.2SDsortl#stNT2SH
#nt&DCDnDmDtempDs#PeH
/lrs/rBEH
pr#nt-BXRt Creat#ng two arra,>EH
pr#nt-BXRn :nter the s#Pe o- -#rst l#st:>EH
s/an-BX%!>DJnEH
pr#nt-BXRn :nter the elements:>EH
-or B#=2H#<nH#GGE
s/an-BX%!>DJl#st1N#SEH
pr#nt-BXRn :nter the s#Pe o- se/on! l#st:>EH
s/an-BX%!>DJmEH
pr#nt-BXRn :nter the elements:>EH
-orBC=2HC<mHCGGE
s/an-BX%!>DJl#st.NCSEH
s#Pe=nGmH
-orB#=2H#<nH#GGE
sortl#stN#S=l#st1N#SH
-orBC=2HC<mHCGGE
sortl#stNnGCS=l#st.NCSH
-orB#=2H#<s#PeO1H#GGE
A
-orBC=#G1HC<s#PeHCGGE
A
&-Bsortl#stN#S>sortl#stNCSE
A
temp=sortl#stN#SH
sortl#stN#S=sortl#stNCSH
sortl#stNCS=tempH
I
I
I
Pr#nt-BXRn elements o- -#rst l#st:>EH
-orB#=2H#<nH#GGE
pr#nt-BXRt %!>Dl#st1N#SEH
-orBC=2HC<mHCGGE
pr#nt-BXRt %!>Dl#st.NCSEH
Pr#nt-BXRn merge! an! sorte! l#st:>EH
-orB#=2H#<nH#GGE
pr#nt-BXRt %!>Dsortl#stN#SEH
get/hBEH
I
OUTPUT!
C0:%(&*W (8) %00%F3
:nter the s#Pe o- the -#rst l#st : 3
:nter the elements : 1 3 1
:nter the s#Pe o- the se/on! l#st : 3
:nter the elements : . T Z
:lements #n the -#rst l#st : 1 3 1
:lements #n the se/on! l#st : . T Z
6erg#ng an! sort#ng l#st : 1 . 3 T 1 Z
MERGING AND SORTING
(:3(O&'
(:3(
':3C0&P(&)*
(:3( 3(:P3
:YP:C(:'
)@(P@(
%C(@%L
)@(P@(
3(%(@3
(CO3)0(O21 %//eptan/e
o- g#"en no
o- arra,
elements
-or arra,
l#st1NS
&nput arra,
elements
%//ept#ng
g#"en
num+er o-
arra,
elements
%//epte!
g#"en
num+er o-
arra,
elements
3u//ess
(CO3)0(O2. *onO
a//eptan/e
o- more
than g#"en
num+er o-
arra,
elements
&nput arra,
elements
(he "alue
-or
l#st1NnG1S
shoul! not
+e a//epte!
(he "alue
-or
l#st1NnG1S
#s not
a//epte!
3u//ess
(CO3)0(O23 *onO
a//eptan/e
o-
/hara/ter
-or the
arra,
elements
&nput /har
[x\
(he "alue
-or
l#stNnG1S
shoul! not
+e a//epte!
(he "alue
-or
l#st1NnG1S
#s not
a//epte!
3u//ess
(CO3)0(O2T 6erg#ng two
arra,s
&nput !ata (he sorte!
l#st ha"e
nGm num+er
o- arra,
elements
(he "alue
-or
l#st1NnG1S
#s not
a//epte!
3u//ess
(CO3)0(O21 3orte!
arra,
elements
&nput !ata %rra,
elements
are sorte!
#n
as/en!#ng
(he "alue
-or
l#st1NnG1S
#s not
a//epte!
3u//ess
or!er
PALINDROME
##n/lu!e<#ostream.h>
##n/lu!e<str#ng.h>
##n/lu!e</on#o.h>
"o#! ma#nBE
A
/lrs/tBEH
/har aH
/har ?strDstr1N.1SH
/ount<<>RnRnRt pal#n!rome>H
/ount<<>RnRnRt ?????????>H
/ount<<>Rn enter the str#ng>H
/#n.getl#neBstrD12EH
str/p,Bstr1DstrEH
strre"BstrEH
#-Bstr/mpBstr1DstrE==2E
A
/ount<<>Rn result #s:>H
/ount<<>Rn ???????:>H
/ount<<>Rn th#s #s a pal#n!rome:>H
I
elseA
/ount<<>Rn result #s:>H
/ount<<>Rn ???????:>H
/ount<<>Rn th#s #s not a pal#n!rome:>H
I
get/hBEH
I
OUTPUT!
P%L&*'0)6:
:nter the str#ng : ma!am
0esult #s : (h#s #s a Pal#n!rome
PALINDROME
(:3(O&'
(:3(
':3C0&P(&)*
(:3( 3(:P3
:YP:C(:'
)@(P@(
%C(@%L
)@(P@(
3(%(@3
(COP%LO21 %//eptan/e
o- numer#/
/hara/ter #n
#nput str#ng
&nput
#nterger
*um+er
*umer#/
"alue
shoul! +e
a//epte!
*umer#/
"alue
a//epte!
3u//ess
(CO P%L O2. *onO
a//eptan/e
o- str#ng
not more
than 12 /har
&nput onl,
str#ng
w#th#n 12
/har
3tr#ng more
than 12
/har shoul!
not +e
a//epte!
3tr#ng>12
/har
a//epte!
5a#lure
6o!#-, /#n.getl#neBstrD12E to /#ngetl#neBstrD12E an! run the program o- (:3(O
&'
(COP%LO2.
(CO P%L O2. *onO
a//eptan/eo-
str#ng not
more than 12
/har
&nput onl,
str#ng w#th
#n 12 /har
3tr#ng more
than 12
/har shoul!
not +e
a//epte!
3tr#ng not
a//epte!
3u//ess
(CO P%L O23 0e"erse
operat#on
per-orme!
+ut not
!#spla,e!
&nput the
str#ng
3tr#ng
a-ter
re"erse
shoul! not
+e
!#spla,e!
0e"erse
str#ng #s
!#spla,e!
5a#lure
6o!#-, strre"BstrE that #s a"o#! strre"BE an! run the program o- (:3(O&' (CO
P%L O23
(CO P%L O23 0e"erse
operat#on
per-orme!
+ut not
!#spla,e!
&nput the
str#ng
3tr#ng
a-ter
re"erse
shoul! not
+e
!#spla,e!
0e"erse
str#ng not
!#spla,e!
3u//ess
(CO P%L O2T 3tr#ng not a
pal#!rome
are re"erse!
&nput the
str#ng
3tr#ng not
a pal#!rome
#s a//epte!
Pal#n!rome
str#ng not
a//epte!
3u//ess
(CO P%L O21 3tr#ng #s
pal#!rome
onl, #- +oth
are e=ual
Cop, the
#nput
str#ng to
the
!est#nat#on
str#ng
:=ual
num+er o-
/hara/ters
shoul! +e
o+ser"e!
3tr1 #s
same as str
su//ess
STUDENT DETAILS
##n/lu!e<st!#o.h>
##n/lu!e</on#o.h>
"o#! ma#nBE
A
#nt m1Dm.Dm3DmTDmTDm1DtotH
/lrs/rBEH
pr#nt-BXRt 3tu!ent !eta#ls>EH
pr#nt-BXRnRt ??????????ls>EH
pr#nt-BXRn :nter the tam#l su+Ce/t mar;:>EH
s/an-BX%!>DJm1EH
pr#nt-BXRn :nter the engl#sh su+Ce/t mar;:>EH
s/an-BX%!>DJm.EH
pr#nt-BXRn :nter the maths su+Ce/t mar;:>EH
s/an-BX%!>DJm3EH
pr#nt-BXRn :nter the s/#en/e su+Ce/t mar;:>EH
s/an-BX%!>DJmTEH
pr#nt-BXRn :nter the so/#al s/#en/e su+Ce/t mar;:>EH
s/an-BX%!>DJm1EH
tot = m1Gm.Gm3GmTGm1H
pr#nt-BXRn (otal: %!>DtotEH
#-Bm1>3 JJ m.>3 JJ m3>3 JJ mT>3 JJ m1>3EA
pr#nt-BXRn 0esult: P%33>EH
I
elseA
pr#nt-BXRn 0esult: 5%&L>EH
I
get/hBEH
I
OUTPUT!
3(@':*( ':(%&L3
?????????????
:nter thetam#l su+Ce/t mar; : 91
:nter theengl#sh su+Ce/t mar; : 9Z
:nter themaths su+Ce/t mar; : 2
:nter the s/#en/e su+Ce/t mar; : 1
:nter the so/#al s/#en/e su+Ce/t mar; : 92
(otal : T3.
0esult : P%33
STUDENT DETAILS
(:3(O&'
(:3(
':3C0&P(&)*
(:3( 3(:P3
:YP:C(:'
)@(P@(
%C(@%L
)@(P@(
3(%(@3
(CO3(@'O21 %//eptan/e
o- s#ngle
!#g#t #n
mar;s
&nput
s#ngle
!#g#t
num+er
3houl! +e
a//epte!
$alue
a//epte!
3u//ess
(CO 3(@'
O2.
%//eptan/e
o- numer#/
"alue #n
result
&nput
numer#/
"alue
*umer#/
"alue
shoul! +e
a//epte!
*umer#/
"alue not
a//epte!
5a#lure
6o!#-, "alue m1 to m1 an! run the program (:3(O&' (CO3(@'O2. aga#n
(CO 3(@'
O2.
%//eptan/e
o- numer#/
"alue #n
result
&nput
numer#/
"alue
*umer#/
"alue
3houl! +e
a//epte!
&nput "alue
a//epte!
3u//ess
(CO 3(@'
O23
Wet the
#nput -#rst
an! then
!#spla,
&nput all
the !eta#ls
-#rst
'eta#ls
shoul! +e
get -#rst
an! then
!#spla,e!
@ser #nput
a//epte!
-#rst an!
!#spla,e!
su//ess
(CO 3(@'
O2T]
'#spla,#ng
Xpass> e"en
mar;s<3
&nput "alue
<3
'#spla,
Xpass> #n
result
'#spla,
X-a#l> #n
result
5a#lure
6o!#-, m1>3Dm.>3Dm3>3 to m1<3Dm.<3Dm3<3 an! run the program o- (:3(O&'
(CO3(@'O2T aga#n
(CO 3(@'
O2T
'#spla,#ng
Xpass> e"en
mar;s<3
&nput
"laue<3
'#spla,
Xpass> #n
result
'#spla,
Xpass> #n
result
3u//ess
(CO 3(@'
O21
*on
a//eptan/e
o- null
"alue #n
mar;s
&nput null
"alue #n
mar;s
*ull "alue
shoul! not
+e a//epte!
*ull "alue
a//epte!
5a#lure
STACK OPERATION
##n/lu!e<st!#o.h>
##n/lu!e</on#o.h>
"o#! ma#nBE
A
#nttopD/hD#DCDsta/;N12SH
/har /H
/lrs/rBEH
pr#nt-BXRn Rt Rt 3(%C^ )P:0%(&)*>EH
pr#nt-BXRn Rt Rt ???????????????>EH
pr#nt-BXRn :nter the range o- the sta/; elements :>EH
s/an-BX%!>DJtopEH
pr#nt-BXRn :nter the sta/; elements :>EH
-orB#=2H#<topH#GGE
s/an-BX%!>DJsta/;N#SEH
!o
A
pr#nt- BXRn Rt 1.P@34>EH
pr#nt- BXRn Rt ..P)P>EH
pr#nt- BXRn Rt 3.L&3(>EH
pr#nt- BXRn :nter ,our /ho#/eB1/./3E:>EH
s/an-BX%!>DJ/hEH
sw#t/hB/hE
A
Case 1:
&-Btop>=12E
Pr#nt- BXRn 3(%C^ &3 5@LL>EH
:lse
A
pr#nt- BXRn :nter the element :>EH
s/an- BX%!>Dsta/;NtopSEH
top = top G 1H
I
7rea;H
Case .:
&-Btop<=2E
Pr#nt- BXRn 3(%C^ &3 :6P(F>EH
:lse
A
pr#nt- BXRn (he pope! element #s : %!>Dsta/;Ntop O1SEH
top = top O 1H
I
7rea;H
Case 3:
Pr#nt- BXRn 3ta/; elements are:>EH
5orB#=2H#<topH#GGE
Pr#nt-BXRt %!Dsta/;N#S>EH
7rea;H
I
Pr#nt-BXRn 'o ,ou want to /ont#nue B,/nE:>EH
C = get/hBEH
I
8h#leB/V=\n\EH
I
OUTPUT!
:nter the range o- the sta/; elements : 3
:nter the sta/; elements : 1 . 3
1.P@34
..P)P
3.L&3(
:nter ,our /ho#/eB1/./3E : 1
:nter the element : T
'o ,ou want to /ont#nue B,/nE : F
1.P@34
..P)P
3.L&3(
:nter ,our /ho#/eB1/./3E : 3
3ta/; elements are : 1 . 3 T
'o ,ou want to /ont#nue B,/nE : F
1.P@34
..P)P
3.L&3(
:nter ,our /ho#/eB1/./3E : .
(he poppe! elements #s : T
'o ,ou want to /ont#nue B,/nE : F
1.P@34
..P)P
3.L&3(
:nter ,our /ho#/eB1/./3E : 3
3ta/; elements are : 1 . 3
'o ,ou want to /ont#nue B,/nE : n
STACK OPERATION
(:3(O&'
(:3(
':3C0&P(&)*
(:3( 3(:P3
:YP:C(:'
)@(P@(
%C(@%L
)@(P@(
3(%(@3
(CO3(%C^O21 %//eptan/e
o- g#"en no
o- sta/;
elements
&nput sta/;
elements
%//ept#ng
g#"en
num+er o-
elements
%//epte!
g#"en
num+er o-
elements
3u//ess
(CO 3(%C^
O2.
*onO
a//eptan/e
o- more
than s#Pe
o- arra,
&nput sta/;
elements
Large
num+er o-
elements
then the
arra,
shoul! not
+e a//epte!
:lements
larget than
the s#Pe o-
the arra,
not
a//epte!
3u//ess
(CO 3(%C^
O23
Pop up the
empt, sta/;
&nput !ata 3ta/; #s
empt,
3ta/; #s
empt,
3u//ess
(CO 3(%C^
O2T
Push #nto
-#lle!
sta/;
&nput !ata 3ta/; #s
-ull
3ta/; #s
-ull
3u//ess
(CO 3(%C^
O21
%//eptan/e
o- !ata -or
the
"ar#a+le /
o- user
/ho#/e
&nput an,
/har !ata
Xn>
(erm#nat#ng
the
exe/ut#on
(erm#nates
the
exe/ut#on
3u//ess
(CO 3(%C^
O2Z
%//eptan/e
o- !ata -or
the
"ar#a+le /
o- user
/ho#/e
&nput an,
/har !ata
Xa>
(he loop
shoul! +e
/ont#nue
Loop
/ont#nues
3u//ess
(CO 3(%C^
O2_
'#spla,s
sta/;
element
w#thout
sort#ng
&nput a
sta/;
element
3ta/;
element
shoul! not
+e sorte!
3ta/l
element not
store!
3u//ess
(CO 3(%C^
O29
'e/rement
o- sta/;
s#Pe #- an
elements #s
poppe!
Pop an!
element
3ta/;
element
shoul! +e
!e/remente!
3ta/;
element
!e/remente!
3u//ess
QUEUE OPERATION
##n/lu!e<st!#o.h>
##n/lu!e</on#o.h>
"o#! ma#nBE
A
#ntnD#D=N12SD?ptrN12SD/hDrear=2D-ront=2H
/har /H
/lrs/rBEH
pr#nt-BXRn Rt Rt `@:@: )P:0%(&)*>EH
pr#nt-BXRn Rt Rt ???????????????>EH
pr#nt-BXRn :nter the range :>EH
s/an-BX%!>DJnEH
pr#nt-BXRn :nter the =ueue elements :>EH
-orB#=2H#<nH#GGE
A
s/an-BX%!>DJ=N#SEH
ptrN#S=J=N#SH
I
0ear =nH
%ga#n:
pr#nt- BXRn Rt 1.%''>EH
pr#nt- BXRn Rt ..':L:(:>EH
pr#nt- BXRn Rt 3.L&3(>EH
pr#nt- BXRn :nter ,our /ho#/eB1/./3E:>EH
s/an-BX%!>DJ/hEH
sw#t/hB/hE
A
Case 1:
&-Brear==12E
Pr#nt- BXRn `@:@: &3 5@LL>EH
:lse
A
pr#nt- BXRn :nter the element :>EH
s/an- BX%!>D=NrearSEH
ptrNrearS=J=NrearSH
rear = rear G 1H
I
7rea;H
Case .:
&-Brear==-rontE
Pr#nt- BXRn `@:@: &3 :6P(F>EH
:lse
A
pr#nt- BXRn (he 'elete! element #s : %!>D=N-rontSEH
-rontGGH
I
7rea;H
Case 3:
&-Brear==-rontE
Pr#nt- BXRn `@:@: &3 :6P(F>EH
:lse
A
Pr#nt- BXRn `ueue elements are:>EH
5orB#=-rontH#<rearH#GGE
Pr#nt-BXRt %!D?ptrN#S>EH
I
7rea;H
I
Pr#nt-BXRn 'o ,ou want to /ont#nue B,/nE:>EH
C = get/hBEH
&-B/==\,\ aa /==\F\E
Woto aga#nH
I
OUTPUT!
:nter the range o- the =ueue elements : 3
:nter the =ueue elements : 1 3 1
1.a!!
..!elete
3.l#st
:nter ,our /ho#/eB1/./3E : .
'elete! element #s : 1
'o ,ou want to /ont#nue B,/nE : F
1.a!!
..!elete
3.l#st
:nter ,our /ho#/eB1/./3E : 3
3ta/; elements are : 3 1
'o ,ou want to /ont#nue B,/nE : n
QUEUE OPERATION
(:3(O&'
(:3(
':3C0&P(&)*
(:3(
3(:P3
:YP:C(:'
)@(P@(
%C(@%L
)@(P@(
3(%(@3
(CO`@:@:O21 *onOa//eptan/e
o- the -#rst
elements #n
the =ueue #-
the -ront an!
rear are not
Pero
&nput
=ueue
elements
5#rst
element
shoul! not
+e a//epte!
5#rst
element #s
not
a//epte!
3u//ess
(CO `@:@:
O2.
*onOa//eptan/e
o- negat#"e
elements #n
the =ueue
&nput
negat#"e
elements
:lements
shoul! not
+e a//epte!
:lements
not
a//epte!
3u//ess
(CO `@:@:
O23
*onOa//eptan/e
o- /hara/ter
#n /ho#/e
&nput
/hara/ter
!ata
Chara/ter
!ata shoul!
not +e
a//epte!
Chara/ter
!ata not
a//epte!
3u//ess
(CO `@:@:
O2T
*onOa//eptan/e
o- =ueue
elements #-
rear=n
&nput the
elements
:lements
shoul! not
+e a//epte!
:lements
not
a//epte!
3u//ess
(CO `@:@:
O21
0ear
#n/rements +,
one #- an
element #s
a!!e! to the
=ueue
&nput an
element
0ear shoul!
+e
#n/remente!
to a!! the
element to
the =ueue
`ueue
#n/rement s
+, one
3u//ess
(CO `@:@:
O2Z
`ueue #s empt,
#- rear an!
-ront #s Pero
L#st out
the =ueue
elements
`ueue
shoul! +e
empt,
`ueue #s
empt,
3u//ess
(CO `@:@:
O2_
Loop /ont#nues
to the next
/ase #- +rea;
statement #s
a"o#!e!
0emo"e
the +rea;
statement
Loop shoul!
exe/ute the
next /ase
also
Loop
/ont#nues
3u//ess
(CO `@:@:
O29
:lements #n
the =ueue are
not store!
&nput
ran!om
element
:lement
shoul! +e
!#spla,e!
as #t #s
:lements
are
!#spla,e!
as #t #s
3u//ess

Das könnte Ihnen auch gefallen