Title: ' "
1???? ????? ?????? ?' ???"?
????? ???? ????? ?????
www.cs.tau.ac.il/armon/prog06a.htm
2?????? ?????
- ??? ?????? ??????-??.
- ????? ????? ?????.
- ????? ???? ???? ????? ?????? ?????.
- ????? ????? ????? ????.
3????? ?????? ?? ????? ?????
- ???? OR ??? ??? ?????, ?? ??? ??? ?????? ?? ????
?? ??????, ?? ??? ???? ????? ??? true (??????
????? ????? ?????). - ???? ??? ?? 0n ?? ????? ???? ?? ????, ????
??? ??? ?????? - if ((n 0) (k/n lt 0.5))
-
- ????? ????, ???? AND ??? ??? ?????, ?? ??? ??? ??
?????? ?? ??? ???? ????? ??? false, ???? ???
?????? ?- AND ?? ??????. - ???? ?? curNULL ?? ????? ???? ?? ???? (???
???? ?????) - while ((curr ! NULL) (curr-gtdata ! val))
- ????-??? ?? ??????? ?? ?????? ???? ????? (?????
???? ????? ???? ????? ????? ??????), ??? ??????
??? ?????? ??.
4????? ????? ???? ?????? ??????
?????? ????? ???? ????? ???? ??????
- Item Find(Item head, int val)
-
- Item curr head
- while ((curr ! NULL) (curr-gtdata ! val))
- curr curr-gtnext
- return curr
?? ??? ?? ????? ???? ??? ????? ?? ????, ???????
?????? ??? ????????.
??????? ???? ?????? ?? ????, ??????? ????? ?????
?????? ????
?? val ?? ???? ??????, ?? ???? ???????
??????? ????? ?????? ?- curr ??? NULL, ??? ??
???? ???? ?? curr-gtdata, ?? ??? ???? ???? (??
???? ?????? NULL).
5??? ????? ??????-?? "???" ?- lcc
- ????? ??????? ?? ???? (?? ????? ??????) ??????
??? ?? ???? ???? (????? ??-???? ?????? ???? ?"?
?????). ???? ??-???? ????? - int size10
- int arraysize
- ????? ?????????? ?? lcc ????? ????? ????, ???
????? ????? ?? ???? ????? ?"? ????? ?????? size. - ??? ?????? ??-?????? ????, ??????? ????? ???????.
- ?? ?????? ??? ????? ?? ????????? ????? ???.
6????? ?? ??????? ?????
7?? ????? ?????
- ???? ?? ?? ???? ???? ??? ?? ?????.
- ????? ?? ??? ?????? C, ????
- ?????? ?????? ???? (???? ????????-????? ??????)
????? ????? "?????? ?????" (????????). - ????? ?????? ????? ?????? ???? (??????-??????,
??????, ???????), ?????? ????? ????? (?????,
???????, ?????? ???????). - ????? ??? ?????? ?????? ?- C ?????? ????? ?????.
8????? ????? ?????
- ?????? ???????, ???/??? ??????? ?????
- ????? if ?- switch ??????? ??????
- ?????? while, for, do while
- ????????
- ??????
- ???????
- ???????
- ???????
- ?????
- ????? ?????? ???????
- ?????? ???????
- ????? ?????? (?? ????? ?????)
9??? ?? ??? ???? ???? C?
- ?????? ????? ???? ?? ??? C, ???? ??? ?????? ????
?????? (??? ?????? ????? ????????) ?????? ???
????????-????? ????????? (??? ?????? ?? ????). - ???? ???? ????, ???? ????? ?????? ?????? ????????
???????? ?????? ???????? (???? ????? ??? ????
DNA, ??????? ???????, ??????? ?????????)
???????/?????? ???? (??? ?? ???? ?? ???? ??????).
- ???? ??????? ?? ???? ?? ????? ??? ???? ?????
?????? ????????? ????? ??? ????? (????-??? ????
????? ??????? ?????? ???? ?????? ???????? ????
?????? ???????? ??? ?????? ?????).
10?? ??? ?? ?-"???? ??????"?
- ?? ???? ????? ??????, ???????? ??????? ?? ??????
?? C - ???? C, Java. ?? ????? ????? ?? ?????? ???
????. - ????? ????? ?????? ???? ????? ??"? ???
Object-Oriented-Programming ("????? ?????-?????")
- ?????? ??????-?????? ????? (classes) ???????
????? ?? ?????? ??? ???????? ??????? ?? ?????
??????? ???. -
- ??? ??? ?? ??????? ????????. ???? ???????? ?- C
?- Java ???? ????-??? ???? ??? ???? ?- C.
11?? ??? ?? ??????/?????-??????
- ????? ??????? ?? ???????
- ?????????? (????-??????) ???????? ??????? ????
??????? ??????, ???????? ?? ???-?????. - ???? ??? ?????? ??????? ????? nxn ????? ??? ????
n3 ??????, ????? ????? ??? ???? ???? ??????
????-???? ?? n2.5 ??????. - ???? ?????? ?????? ?????? ???? ?? ???? ??? ????
???????. - ????? ???? ?? ??????? ????? ???? ?????? ??
????????? - ?????? ??? ??????? ???? ?????? ?? ??? ?????
- ???? ????? ?? ??????? ????? ?????-????? ????
??????? ?????? - ??? ???? ?????? ????? ?????? ?? ????? ??? ??????
????????. - ????????? ???????? ?????? (??? ?????? ???????
?????? ??????) ?????? ????? ?????-???? ?? ?????
????-???? ?????. ?? ????? ????-??? ??????, ?"?
???? ?????, ???? ??? ?????? ?? ????. ???? ?????
???? ?? ????? ?????? ???.
12??????
13????? ?? ?????
14???? ?????
- ????? ???? ???? ?????, 26/2/06, ???? 900.
- ??? ????? ????? ????? ???? ???? ???? ??????
(????? ?? 1230). - ????? ???? ??? ????? ?????-???.
15???? ?????
- ???? ????? ???? ????? ???? ??? ?? ????? ????????,
????? ???? ???? ????? ????-???? - ????? ??? ????? ???????/???????? ????? ?????
????? ?? ????? ?????? (?? ?? ?????, ?? ?????
???). ?? ???? ????? ????? ???????. - ?????? ?????? ???? ????? ???????? ?? ???????
????? (????-??? ?? ???? ?????? ?-2-3 ??????).
16????? ?????
- ????? ???? ?? ?? ?? ???? ???????, ?????????,
????????-????. - ???? ??????? ?????, ??? ?????? ????? (?? ?? ?????
??????? ?????) - ?????
- ????? ??????? ?- main (argc,argv)
- ?????? ??-??????? (????? ?? ?????? ??-??????? ??
?????? ?????)
17????? ????? ?????
- ????? ??????? ??? ???? ?? ?????? ?????????, ?????
????? ?? ?? ??????, ????????, ????????? ????????. - - ??? ??? ??? ?? ?? ?????? ???????-??? ?????
????? ?????, ?? ????? ????? ??? ?? ????????
???????? ???? ???????. -
- ?? ????? ????? ???, ???? ?????? ?? ?????? ??????.
- ?????? ???? ?' ????? ?' ????? ????? ?????? ????
?????, ??? ?? ???????? ???? ??????? ????. - ????? ??? ????? ?? ????? ??????, ??? ?? ??????
??????.
18???? ?????? ????? ????
- ???? ????? ????? ?? ?????? ?????? ?????? ????? ??
?? ???????. - ?? ???? ??-?????? ????? ???? ????? ????? ?? ????
????? ?? ????? ?? ?? ???????? (?????? ??? ????
?????). - ?? ?????? ????? ?????, ???? ????? ???? ??????
???? ?????. - ?? ?? ??? ?? ???? ????? ?? ??????? ??? ???? ?????
?????? ???? ????.
19????-???? ???? ?????
- ????? ????? ???-????? ?????? ???? ????? ?????
1400-1500. - ???? ?????, 23/2/06, ??? ????? ????? ?- 1300.
- ????? ???? ?? ???? ???? ??? ?????
armon_at_post.tau.ac.il - ????-????? ?? ?????? ??????, ???? 1-,
?-open-space (????? ?????? ??? ??? ??? 2, ???
???-???????). - ??????? ??????? ???? ????? (??? ?????? ????? ??
????).
20?????
21??????
22??????? ?????? ?????
23???? 5 ????? ???? ?' ???"?
- ???? 5 (25 ??????)
- ???? ?' (5 ??????)
- ?????? ???? (structure) ??? ???? ?????? ?????
?????? ??? ???? ?????? ????? (??? ?????). -
24???? 5 ????? ?' ???"?
- ???? ?' (5 ??????)
- ?????? ???? (structure) ??? ???? ?????? ?????
?????? ??? ???? ?????? ????? (??? ?????). -
- ?????
- struct item
-
- int data
- struct item next
25???? 5 ????? ?' ???"?
- ???? ?' (5 ??????)
- ?????? ???? (structure) ??? ???? ?????? ?????
?????? ??? ???? ?????? ????? (??? ?????). -
- ????? ?? ???? ?????
- typedef struct item_t
-
- int data
- struct item_t next
- item
26???? 5 ????? ?' ???"?
- ???? ?' (10 ??????)
- ???? ??????? ?????? ????? ???? ?????? ???????
?? ???? ??????? ??????.
27???? 5 ????? ?' ???"?
- ???? ?' (10 ??????)
- ???? ??????? ?????? ????? ???? ?????? ???????
?? ???? ??????? ??????. - ?????
- int sum_list(item list)
-
- int sum0
- while (list ! NULL)
-
- sumsumlist-gtdata
- listlist-gtnext
-
- return sum
??????? ?? ????? ?????? ??????? ?? ?????? ???????
???
28???? 5 ????? ?' ???"?
- ???? ?' (10 ??????)
- ???? ??????? ??? ???? ????? ???? ??????, ???
????? ?? ?????? ?????? ????? ?????? ??????
????????.
29???? 5 ????? ?' ???"?
- ???? ?' (10 ??????)
- ???? ??????? ??? ???? ????? ???? ??????, ???
????? ?? ?????? ?????? ????? ?????? ??????
????????. - ???? ??????
- ????? ?? ?????? ??????? ?? ????? ?- NULL.
- ??? ??? ????? ?? ????? ??????, ?????? ???? ????
?????? ????? (?? ??? ????? ?????? ?????? ????? ??
?? ???? ??? ??????). - ?????? ?????? ????? ????? ???? (new_item), ?????
???? ?????? ????? (new_head), ????? ????? ??????
??????? ?????? ????? (new_last).
30- ????? ???? ?' (10 ??????) ????? ?????
- item duplicate(item head)
- item new_item, new_lastNULL,
new_headNULL - while (head ! NULL)
-
- new_item(item ) malloc(sizeof(item))
- new_item-gtdatahead-gtdata
- new_item-gtnextNULL
- if (new_head NULL)
- new_headnew_item
- else
- new_last-gtnextnew_item
- new_lastnew_item
- headhead-gtnext
-
- return new_head
??????? ?? ?????? ???????
????? ?????
?? ??? ????? ?????? ?????? ?????, ?? ?? ???
??????
???? ?????? ????? ????
????? ??????? ??? ????? ??????
??????? ?? ??? ?????? ?????
31????? ???? ?????? ??
- ????? ???????? ??????? ?? ????? ????? ??????,
?????? ?? ?????? ????? ????? ?????? ???? (??????
???? ??????). sum_list(item list),
duplicate(item head) -
- ???? ?? ??? ????? ?? ????? ?? ?????? ?????? ??
??? ?????? ??????? ?????? (?? ????? ????? ?????
????????). ???? ?? ????? ???????? ????????
?????? ??-??? - sum_list(head)
- ?? ???????? ?????? ?????? ?????? ?????? head, ???
?? ?????? ?? ?????? head. ??? ???? ?????? head
??????? ?????? ?? ????? ?????????. - ?????? ????? ???????? ?? ?????? ???? (?? ??????
?? ??????).
32???? 5 ????? ?' ???"?
- int sum_list(item list)
-
- int sum0
- while (list ! NULL)
-
- sumsumlist-gtdata
- listlist-gtnext
-
- return sum
?? ???? ?????? ?????
sum_list(head)
?? ?????? head ?? ?????, ?? ?? ?????? ???????? ??
?? ?????? ?????? ??. ???? ????? ?? list ????????,
??? ????? ?- head.
33???? 1 ????? ?' ???"?
- ???? ??' 1 (25 ??????)
- ???? ??????? ???????? ?? ????? ??? ???????? ?????
(structure) ?????? ????? ??? - struct _Complex
-
- float re / The real part. /
- float im / The imaginary part. /
-
- typedef struct _Complex Complex
- ???-?? ????? ??? ????????
- void complex_set (Complex p_z, float x,
float y) -
- p_z-gtre x
- p_z-gtim y
- return
-
34???? 1 ????? ?' ???"?
- ????? ??? ?????? ????
- int main ()
-
- Complex p_z
- complex_set (p_z, 3, 4)
- / The rest of the program comes here ... /
-
- return (0)
-
-
-
- ?????? "???" ???? ?????. ?? ????? ?????? ??????
?"?????"?
35???? 1 ????? ?' ???"?
- void complex_set (Complex p_z, float x, float y)
-
- p_z-gtre x
- p_z-gtim y
- return
-
- ???? ?' (5 ??????) ????? ??? ?????? ????
- int main ()
-
- Complex p_z
- complex_set (p_z, 3, 4)
- / The rest of the program comes here ... /
-
- return (0)
-
- ?????? "???" ???? ?????. ?? ????? ?????? ??????
?"?????"?
36???? 1 ????? ?' ???"?
- void complex_set (Complex p_z, float x, float y)
-
- p_z-gtre x
- p_z-gtim y
- return
-
- ???? ?' (5 ??????) ????? ??? ?????? ????
- int main ()
-
- Complex p_z
- complex_set (p_z, 3, 4)
- / The rest of the program comes here ... /
-
- return (0)
-
- ?????? "???" ???? ?????. ?? ????? ?????? ??????
?"?????"?
37???? 1 ????? ?' ???"?
- void complex_set (Complex p_z, float x, float y)
-
- p_z-gtre x
- p_z-gtim y
- return
-
- ???? ?' (5 ??????) ????? ??? ?????? ????
- int main ()
-
- Complex p_z
- complex_set (p_z, 3, 4)
- / The rest of the program comes here ... /
-
- return (0)
-
- ?????? "???" ???? ?????. ?? ????? ?????? ??????
?"?????"?
?????? ????? ?- p_z ????? ???? ??? ????? ?? p_z
38- ???? ?' (5 ??????) ????? ??? ????? ????
- int main ()
-
- int n
- Complex values
- int i
- / Read the number from the user /
- printf (Please enter the number of values )
- scanf (d, n)
- / Allocate memory /
- values (Complex ) malloc (8 n)
- / Initially set all complex values to be 0. /
- for (i 0 i lt n i)
- complex_set (values i, 0, 0)
- / The rest of the program comes here ... /
- free (values)
- return (0)
39???? 1? ????? ?' ???"?
- ?????? ?????? ?????, ?? ???? ??????? ????? ??
????? ????? ????, ??-??? ??????? ???? ????? ????
????, ?? ???? ???? ????? - Struct _Complex
-
- double re / The real part. /
- double im / The imaginary part. /
- Complex
- typedef struct _Complex Complex
-
- ?? ???? ?????? ??? ???? ???? ?? ?- main ??? ???
???? ????? ???? -
40???? 1? ????? ?' ???"?
????
struct _Complex float re / The real part.
/ float im / The imaginary part.
/ typedef struct _Complex Complex
- struct _Complex
-
- double re / The real part. /
- double im / The imaginary part. /
- Complex
- typedef struct _Complex Complex
-
-
?????
41- ???? ?' (5 ??????) ?? ????? ???? ???? ?????
- int main ()
-
- int n
- Complex values
- int i
- / Read the number from the user /
- printf (Please enter the number of values
\n) - scanf (d, n)
- / Allocate memory /
- values (Complex ) malloc (8 n)
- / Initially set all complex values to be 0. /
- for (i 0 i lt n i)
- complex_set (values i, 0, 0)
- / The rest of the program comes here ... /
- free (values)
- return (0)
42- ???? ?' (5 ??????) ?? ????? ???? ???? ?????
- int main ()
-
- int n
- Complex values
- int i
- / Read the number from the user /
- printf (Please enter the number of values )
- scanf (d, n)
- / Allocate memory /
- values (Complex ) malloc (8 n)
- / Initially set all complex values to be 0. /
- for (i 0 i lt n i)
- complex_set (values i, 0, 0)
- / The rest of the program comes here ... /
- free (values)
- return (0)
?? ???? ?????, ???? ???? ????? ????? ??? float,
??? ??? ?? ???? ???? double.
43- ???? ?' (5 ??????) ?? ????? ???? ???? ?????
- int main ()
-
- int n
- Complex values
- int i
- / Read the number from the user /
- printf (Please enter the number of values )
- scanf (d, n)
- / Allocate memory /
- values (Complex ) malloc (sizeof(Complex)
n) - / Initially set all complex values to be 0. /
- for (i 0 i lt n i)
- complex_set (values i, 0, 0)
- / The rest of the program comes here ... /
- free (values)
- return (0)
????? ????? ?? ?????
44???? 1 ????? ?' ???"?
- ???? ?' (5 ??????)
- ?? ???? ???????? ????
- void secret (const char s1, char s2)
-
- while (s1)
-
- s2 s1
- s1
- s2
-
- s2 s1
-
45???? 1 ????? ?' ???"?
- ???? ?' (5 ??????)
- ?? ???? ???????? ????
- void secret (const char s1, char s2)
-
- while (s1)
-
- s2 s1
- s1
- s2
-
- s2 s1
-
????? ??????? ???? ??????? ??????? ?? ??????? s1
??????? s2. (??? ????? ??? ???? ?????? ??-??? s2
????? ???? ??????).
46???? 1 ????? ?' ???"?
- ???? ?' (5 ??????)
- ?? ???? ???????? ????
- void secret (const char s1, char s2)
-
- while (s1)
-
- s2 s1
- s1
- s2
-
- s2 s1
-
?? ??? ??? ?????? ?- s1 ???? 0, ????? ?? ?????
???? s1 ('0\')
47???? 1 ????? ?' ???"?
- ???? ?' (5 ??????)
- ?? ???? ???????? ????
- void secret (const char s1, char s2)
-
- while (s1)
-
- s2 s1
- s1
- s2
-
- s2 s1
-
?? ??? ??? ?????? ?- s1 ???? 0, ????? ?? ?????
???? s1 ('0\')
??????? ???? ????? ?????? ?- s2
48???? 1 ????? ?' ???"?
- ???? ?' (5 ??????)
- ?? ???? ???????? ????
- void secret (const char s1, char s2)
-
- while (s1)
-
- s2 s1
- s1
- s2
-
- s2 s1
-
?? ??? ??? ?????? ?- s1 ???? 0, ????? ?? ?????
???? s1 ('0\')
??????? ???? ????? ?????? ?- s2
???????? ???? ????????
49???? 1 ????? ?' ???"?
- ???? ?' (5 ??????)
- ?? ???? ???????? ????
- void secret (const char s1, char s2)
-
- while (s1)
-
- s2 s1
- s1
- s2
-
- s2 s1
-
?? ??? ??? ?????? ?- s1 ???? 0, ????? ?? ?????
???? s1 ('0\')
??????? ???? ????? ?????? ?- s2
???????? ???? ????????
???? ??? ?????? ??????? ?- s2 ???? ?? ?- '\0'
???? ???? s1
50??? ????? ?? ?????????
51??????
- ????? ???? ???? ?????, 26/2/06, ?-900.
- ????? ?? ?? ????? ?? ???????, ?????????,
???????-????, ???? ?????, ????? ??????? ?- main,
??????? ??-???????. - ???? ???? ???? ????? ???? ?????, 23/2/06, ????
1300. - ?? ????? ???? ????? ?????? ???? ????? ?- 1400,
????? ???? ?? ?????? ?????. - ??????? ???? ?? ????? ??????? ????.
52????
53??????!!!