[SOLVED] C Java 3

$25

File Name: C_Java_3.zip
File Size: 75.36 KB

5/5 - (1 vote)

3
3.1
:
:
:
:6
3.2

3.3
1
2
3
4
54
3.4
C

1

1.0

2

1.0

3

1.1

4

1.2

5

1.2

6

1.2

7

1.3

8

1.2

9

1.2

10
B
1.4

11

1.3

12

1.3

13

1.3

1
2.
3.
4.
3.5

AnyviewCLTCCBuilderVCJava
3.6

3.7

517Excel
3.8

1
2
3
4
5

3.9

3.10
1.
List
ADT List
D aiaiElemSet, i1,2,,n,n0
R1 ai1, aiai1, aiD, i2,,n

SetEmptyL
L
DestroyL
L
L
LengthL
L
L
GetL, i, e
L1iLengthListL
eLi
LocateL, e, compare
Lcompare
L1ecompare
0
InsertL, i, e
L1iLengthListL1
LieL1
DeleteL, i, e
L1iLengthListL
LieL1
DisplayL
L
L
ADT List
2
DS0.h:
include conio.h
include stdio.h
include stdlib.h
include string.h
include values.h

define TRUE 1
define FALSE0
define OK 1
define ERROR0
define IBFEASIBLE1
define OVERFLOW2

define MAXLEN20
define MAXSIZE 20

typedef int Status;
typedef char ElemType;

define LISTINITSIZE 20
define LISTINCREMENT10
typedef struct
ElemType elem;
int length;
int listsize;
SqList;

typedef struct LNode
ElemType data;
struct LNode next;
LNode, LList;

typedef struct LNode
ElemType data;
struct LNode next;
LNode, Link, Position;

typedef struct LinkList
Link head,tail;
int len;
LinkList;
3.

Status SetEmptySqList L
L.elemElemTypemallocLISTINITSIZEsizeofElemType;
if!L.elem
return OVERFLOW;
L.length0;0
L.listsizeLISTINITSIZE;
return OK;

Status Destroy SqList LL
freeL.elem;
L.elemNULL;
L.length0;
L.listsize0;
return OK;

int LengthSqList L
return L.length;

Status GetSqList L, int i, ElemType e i
ifi1iL.length
return ERROR;
eL.elemi1;
return OK;

int LocateSqList L, ElemType x x
ElemType p;
int i1;i1
pL.elem;p1
whileiL.lengthp!x
i;
ifiL.length
return i;
else
return 0;

Status InsertSqList L, int i, ElemType e
LieL1
ElemType newbase,q,p;
ifi1iL.length1i
return ERROR;
ifL.length L.listsize ,
newbaseElemTypereallocL.elem,
L.listsizeLISTINCREMENTsizeofElemType;
if!newbase return OVERFLOW;
L.elemnewbase;
L.listsizeLISTINCREMENT;

qL.elemi1;q
forpL.elemL.length1; pq; p
p1p;
qe;e
L.length;1
return OK;

Status DeleteSqList L, int i, ElemType e
L1iListLengthL
LieL1
ElemType p,q;
ifi1i L.lengthi
return ERROR;
p L.elemi1;p
ep;e
q L.elemL.length1;
forp; pq; p
p1p;
L.length;1
return OK;

Status DisplaySqList L
ElemType p;
int i;
pL.elem;
printf ;
fori1; iL.length; i
printfc,p;
printf n;
return OK;

void SetEmptyLList L
LNULL;

Status Destroy LList L
LList qL;
whileL
LLnext;
freeq;
qL;

return OK;

int LengthLList L
int n0;
whileL!NULL
n;
LLnext;

return n;

Status GetLList L, int i, ElemType e i
int j1;
while jiL!NULL
LLnext;
j;

ifL!NULLeLdata;return OK;
else return ERROR;i

int LocateLList L, ElemType x x
int n1;
while L!NULLLdata!x
LLnext;
n;

if LNULL return 0;
else return n;

Status InsertLList L, int i, ElemType e i
int j1;
LList s,q;
sLListmallocsizeofLNode;
sdatae;
qL;
if i1snextq;Ls;return OK;
else
whileji1qnext!NULL
qqnext;
j;

if ji1
snextqnext;
qnexts;
return OK;

else return ERROR; i

Status DeleteLList L, int i, ElemType e i
int j1;
LList qL,t;
if i1
eqdata;
Lqnext;
freeq;
return OK;

else
while ji1qnext!NULL
qqnext;
j;

if qnext!NULLji1
tqnext;
qnexttnext;
etdata;
freet;
return OK;

else return ERROR; i

void DisplayLList L
printf: ;
if LNULL
printf!;
else if LnextNULL
printfcn, Ldata;
else
whileLnext!NULL
printfc, Ldata;
LLnext;

printfc, Ldata;

printfn;

Status SetEmptyLinkList L
Link p;
pLinkmallocsizeofLNode;
ifp
pnextNULL;
L.headL.tailp;
L.len0;
return OK;

else
return ERROR;

Status DestroyLinkList L LL
Link p,q;
ifL.head!L.tail
pq L.headnext;
L.headnextNULL;
whilep!L.tail
pqnext;
freeq;
qp;

freeq;

freeL.head;
L.headL.tailNULL;
L.len0;
return OK;

int LengthLinkList L L
return L.len;

Status GetLinkList L, int i, ElemType e i
i0
Link p;
int j;
ifi1iL.len
return ERROR;
else
pL.head;
forj1;ji;j
ppnext;
epdata;
return OK;

int LocateLinkList L, ElemType x x
int i0;
Link pL.head;
do
ppnext;
i;
whileppdata!x;
if !p
return 0;
else
return i;

Status InsertLinkList L, int i, ElemType e i
int j0;
Link s,q;
sLinkmallocsizeofLNode;
sdatae;
qL.head;
whileji1qnext!NULL
qqnext;
j;

if ji1
snextqnext;
qnexts;
if L.tailq L.tails;
L.len;
return OK;

else return ERROR; i

Status DeleteLinkList L, int i, ElemType e
i
int j0;
Link qL.head,t;
while ji1qnext!NULL
qqnext;
j;

if qnext!NULLji1
tqnext;
qnexttnext;
etdata;
ifL.tailt L.tailq;
freet;
L.len;
return OK;

else return ERROR; i

void DisplayLinkList L
Link p;
printf: ;
if L.headL.tail
printf!;
else
pL.headnext;
whilepnext!NULL
printfc, pdata;
ppnext;

printfc, pdata;

printfn;

4

SqList head;
void main
char e,c;
int i,n,select,x1,x2,x3,x4,m,g;
SetEmptyhead;
nrandom8;
for i1; in; i
cArandom26;
Inserthead,i,c;

do
Displayhead;
printfselect 1Lengthn;
printfselect 2Getn;
printfselect 3Locaten;
printfselect 4Deleten;
printfinput your select: ;
scanfd,select;
switchselect
case 1: x1Lengthhead;
printf:d ,x1;
break;
case 2: printf: ;
scanfd,m;
ifGethead,m,x2 printfcn,x2;
else printfn;
break;
case 3: printf: ;
scanfnc,e;
x3Locatehead,e;
printfdn,x3;
break;
case 4: printf: ;
scanfd,g;
ifDeletehead,g,x4 printfcn,x4;
else printfn;
break;

while select0select 5;

LList head;
void main
char e,c;
int i,n,select,x1,x2,x3,x4,m,g;
SetEmptyhead;
nrandom8;
for i1; in; i
cArandom26;
Inserthead,i,c;

do
Displayhead;
printfselect 1Lengthn;
printfselect 2Getn;
printfselect 3Locaten;
printfselect 4Deleten;
printfinput your select: ;
scanfd,select;
switchselect
case 1: x1Lengthhead;
printf:d ,x1;
break;
case 2: printf: ;
scanfd,m;
ifGethead,m,x2 printfcn,x2;
else printfn;
break;
case 3: printf: ;
scanfnc,e;
x3Locatehead,e;
printfdn,x3;
break;
case 4: printf: ;
scanfd,g;
ifDeletehead,g,x4 printfcn,x4;
else printfn;
break;

while select0select 5;

LinkList head;
void main
char e,c;
int i,n,select,x1,x2,x3,x4,m,g;
SetEmptyhead;
nrandom8;
for i1; in; i
cArandom26;
Inserthead,i,c;

do
Displayhead;
printfselect 1Lengthn;
printfselect 2Getn;
printfselect 3Locaten;
printfselect 4Deleten;
printfinput your select: ;
scanfd,select;
switchselect
case 1: x1Lengthhead;
printf:d ,x1;
break;
case 2: printf: ;
scanfd,m;
ifGethead,m,x2 printfcn,x2;
else printfn;
break;
case 3: printf: ;
scanfnc,e;
x3Locatehead,e;
printfdn,x3;
break;
case 4: printf: ;
scanfd,g;
ifDeletehead,g,x4 printfcn,x4;
else printfn;
break;

while select0select5;

5

SetEmptyL
O1
O1
O1

DestroyL
O1
On
On

LengthL
O1
On
O1

GetL, i, e
O1
On
On

LocateL,e,compare
On
On
On

InsertL, i, e
On
On
On

DeleteL, i, e
On
On
On

DisplayL
On
On
On

1
2

1
2

6
1
2
3

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] C Java 3
$25