ðåôåðàò
Ãëàâíàÿ

Ðåôåðàòû ïî ñåêñîëîãèè

Ðåôåðàòû ïî èíôîðìàòèêå ïðîãðàììèðîâàíèþ

Ðåôåðàòû ïî áèîëîãèè

Ðåôåðàòû ïî ýêîíîìèêå

Ðåôåðàòû ïî ìîñêâîâåäåíèþ

Ðåôåðàòû ïî ýêîëîãèè

Êðàòêîå ñîäåðæàíèå ïðîèçâåäåíèé

Ðåôåðàòû ïî ôèçêóëüòóðå è ñïîðòó

Òîïèêè ïî àíãëèéñêîìó ÿçûêó

Ðåôåðàòû ïî ìàòåìàòèêå

Ðåôåðàòû ïî ìóçûêå

Îñòàëüíûå ðåôåðàòû

Ðåôåðàòû ïî àâèàöèè è êîñìîíàâòèêå

Ðåôåðàòû ïî àäìèíèñòðàòèâíîìó ïðàâó

Ðåôåðàòû ïî áåçîïàñíîñòè æèçíåäåÿòåëüíîñòè

Ðåôåðàòû ïî àðáèòðàæíîìó ïðîöåññó

Ðåôåðàòû ïî àðõèòåêòóðå

Ðåôåðàòû ïî àñòðîíîìèè

Ðåôåðàòû ïî áàíêîâñêîìó äåëó

Ðåôåðàòû ïî áèðæåâîìó äåëó

Ðåôåðàòû ïî áîòàíèêå è ñåëüñêîìó õîçÿéñòâó

Ðåôåðàòû ïî áóõãàëòåðñêîìó ó÷åòó è àóäèòó

Ðåôåðàòû ïî âàëþòíûì îòíîøåíèÿì

Ðåôåðàòû ïî âåòåðèíàðèè

Ðåôåðàòû äëÿ âîåííîé êàôåäðû

Ðåôåðàòû ïî ãåîãðàôèè

Ðåôåðàòû ïî ãåîäåçèè

Ðåôåðàòû ïî ãåîëîãèè

Ðåôåðàòû ïî ãåîïîëèòèêå

Ðåôåðàòû ïî ãîñóäàðñòâó è ïðàâó

Ðåôåðàòû ïî ãðàæäàíñêîìó ïðàâó è ïðîöåññó

Ðåôåðàòû ïî äåëîïðîèçâîäñòâó

Ðåôåðàòû ïî êðåäèòîâàíèþ

Ðåôåðàòû ïî åñòåñòâîçíàíèþ

Ðåôåðàòû ïî èñòîðèè òåõíèêè

Ðåôåðàòû ïî æóðíàëèñòèêå

Ðåôåðàòû ïî çîîëîãèè

Ðåôåðàòû ïî èíâåñòèöèÿì

Ðåôåðàòû ïî èíôîðìàòèêå

Èñòîðè÷åñêèå ëè÷íîñòè

Ðåôåðàòû ïî êèáåðíåòèêå

Ðåôåðàòû ïî êîììóíèêàöèè è ñâÿçè

Êóðñîâàÿ ðàáîòà: ²íôîðìàö³éíî-äîâ³äêîâà ñèñòåìà

Êóðñîâàÿ ðàáîòà: ²íôîðìàö³éíî-äîâ³äêîâà ñèñòåìà

̲ͲÑÒÅÐÑÒÂÎ ÎѲÒÈ ² ÍÀÓÊÈ ÓÊÐÀ¯ÍÈ

ÍÀÖ²ÎÍÀËÜÍÈÉ ÒÅÕͲ×ÍÈÉ ÓͲÂÅÐÑÈÒÅÒ

"ÕÀÐʲÂÑÜÊÈÉ ÏÎ˲ÒÅÕͲ×ÍÈÉ ²ÍÑÒÈÒÓÒ"

Êàôåäðà Îá÷èñëþâàëüíî¿ òåõí³êè òà ïðîãðàìóâàííÿ


ÇÀÒÂÅÐÄÆÓÞ

Çàâ³äóâà÷ êàôåäðè ÎÒÏ

__________ /xxxxxxxxx./

"___" __________ 2007ð.

Ðîçðàõóíêîâî-ãðàô³÷íå çàâäàííÿ ¹ 1, 2

²ÍÔÎÐÌÀÖ²ÉÍÎ-ÄβÄÊÎÂÀ ÑÈÑÒÅÌÀ

Ñïåöèô³êàö³ÿ

ËÈÑÒ ÇÀÒÂÅÐÄÆÅÍÍß

Xxxxxxxx

Ðîçðîáíèêè

Êåð³âíèê ïðîåêòó

__________ /äîö. xxxxxxx./

"___" __________ 2007 ð.

Âèêîíàâåöü

__________ /ñòóä. xxxxxxx./

"___" __________ 2007 ð.

2007
ÓÇÃÎÄÆÅÍÎ

xxxxxxxxxxxxxx

Ðîçðàõóíêîâî-ãðàô³÷íå çàâäàííÿ ¹ 1, 2

²ÍÔÎÐÌÀÖ²ÉÍÎ-ÄβÄÊÎÂÀ ÑÈÑÒÅÌÀ

Ñïåöèô³êàö³ÿ

xxxxxxxxxxxxx

2007

Ôîðìàò Ïîçíà÷åííÿ Íàéìåíóâàííÿ ʳëüê³ñòü Ïðèì³òêà
À4 Xxxxxxxxxxx-01 81 ÒÇ Òåõí³÷íå çàâäàííÿ 2
À4 Xxxxxxxxxxx-01 81 ÏÇ Ïîÿñíþâàëüíà çàïèñêà 6
À4 Xxxxxxxxxxx-01 81 ÎÏ Ïðîãðàìà òà ìåòîäèêà ³ñïèò³â 2
À4 Xxxxxxxxxxx-01 81 ÒÏ Òåêñò ïðîãðàìè 4-6

̲ͲÑÒÅÐÑÒÂÎ ÎѲÒÈ ² ÍÀÓÊÈ ÓÊÐÀ¯ÍÈ

ÍÀÖ²ÎÍÀËÜÍÈÉ ÒÅÕͲ×ÍÈÉ ÓͲÂÅÐÑÈÒÅÒ

"ÕÀÐʲÂÑÜÊÈÉ ÏÎ˲ÒÅÕͲ×ÍÈÉ ²ÍÑÒÈÒÓÒ"

Êàôåäðà Îá÷èñëþâàëüíî¿ òåõí³êè òà ïðîãðàìóâàííÿ

ÇÀÒÂÅÐÄÆÓÞ

Çàâ³äóâà÷ êàôåäðè ÎÒÏ

__________ /xxxxxxxxx./

"___" __________ 2007ð.

Ðîçðàõóíêîâî-ãðàô³÷íå çàâäàííÿ ¹ 1, 2

²ÍÔÎÐÌÀÖ²ÉÍÎ-ÄβÄÊÎÂÀ ÑÈÑÒÅÌÀ

Òåõí³÷íå çàâäàííÿ

ËÈÑÒ ÇÀÒÂÅÐÄÆÅÍÍß

Xxxxxxxxxxx-01 81 01-1-ËÇ

Ðîçðîáíèêè

Êåð³âíèê ïðîåêòó

__________ /äîö. xxxxxxx./

"___" __________ 2007 ð.

Âèêîíàâåöü

__________ /ñòóä. xxxxxxxx./

"___" __________ 2007 ð.

2007
1. Âñòóï

Ó äàíîìó ðîçðàõóíêîâîìó çàâäàíí³ ðîçãëÿíóòèé ïîë³ìîðôíèé ñïèñîê îá'ºêò³â. Òåõí³÷í îñîáëèâîñò³ ïðîãðàìè ðîçãëÿíóò³ íèæ÷å.

2. ϳäñòàâà äëÿ ðîçðîáêè

ϳäñòàâîþ äëÿ ðîçðîáêè ïðîãðàìè º îòðèìàííÿ çàâäàííÿ çà òåìîþ «²íôîðìàö³éíî-äîâ³äêîâà ñèñòåìà».

3. Ìåòà ³ ïðèçíà÷åííÿ ðîçðîáêè

Ìåòà ðîáîòè çàñâî¿òè ïðèíöèï âèêîðèñòàííÿ ïîë³ìîðôíèõ ñïèñê³â îá'ºêò³â ³ ðåàë³çóâàòè ðîáîòó ïðîãðàìíîãî çàáåçïå÷åííÿ , ùî âèêîðèñòîâóº ö³ ïðèíöèïè. Ïðîãðàìà ïðèçíà÷àºòüñÿ äëÿ îáðîáêè òàáëèöü äàíèõ.

4. Âèìîãè äî ðîçðîáêè

Ðîçðîáëåíà ïðîãðàìà ïîâèííà âèêîíóâàòè òàê ïóíêòè:

-      Ñòâîðåííÿ ïîë³ìîðôíîãî ñïèñêó îá’ºêò³â;

-      Âèâ³ä éîãî íà åêðàí;

-      Çàíåñåííÿ ó ôàéë;

-      Ç÷èòóâàííÿ ç ôàéëó;

-      Ïîøóê çàïèñó;

-      Ðåäàãóâàííÿ çàïèñó;

-      Âñòàâêà íîâîãî çàïèñó;

-      Çíèùåííÿ çàïèñó;

-      Âèêîíàííÿ çàäà÷³;

-      Âèõ³ä.

5. Ñòà䳿 òà åòàïè ðîçðîáêè

1. Ñòâîðåííÿ êëàñ³â;

2. Çàñòîñóâàííÿ ïîë³ìîðô³çìó;

3. Ñòâîðåííÿ äâîíàïðàâëåíîãî ñïèñêó òà ðîáîòà ç íèì;

4. Âò³ëåííÿ ìîæëèâîñòåé äëÿ äàíî ïðîãðàìè, ðîçãëÿíóòèõ ó ï.4;

5. Ââ³ä òà âèâ³ä ³íôîðìàö³¿.

6. Ïîêàç ðåçóëüòàò³â.

6. Ïîðÿäîê êîíòðîëþ òà ïðèéîìêè

Ðîçðîáëåíå ïðîãðàìíå çàáåçïå÷åííÿ ïîâèííî:

- âèêîíóâàòè àñîö³àòèâíèé ïîøóê äàíèõ íà îñíîâ³ ðîçðîáëåíîãî àëãîðèòìó;

- ëåãêî àäàïòóâàòèñÿ ïðè ìîäèô³êàö³¿ ñòðóêòóðè äàíèõ;

- çàáåçïå÷óâàòè äðóæí³é ³íòåðôåéñ ³ç êîðèñòóâà÷åì ³ ìîæëèâ³ñòü íàñòðîþâàííÿ ïàðàìåòð³â äåðåâà â ä³àëîãîâîìó ðåæèì³.

³äìîâëåííÿ ÅÎÌ ó ðîáîò³ íå ïîâèííèé ïðèâîäèòè äî çíà÷íèõ âòðàò ³íôîðìàö³¿.

Ðîçðîáëþâàëüíå ïðîãðàìíå çàáåçïå÷åííÿ ìຠôóíêö³îíóâàòè â ñåðåäîâèù³ MS-DOS òà Windows ïîâèííèé áóòè íàïèñàíèé ìîâîþ C++/Ñ.

7. Ïðîãðàìíà äîêóìåíòàö³ÿ

Äëÿ ðîçðîáëþâàëüíîãî âèðîáó ïîâèíí áóòè ñêëàäåí³ ïðîãðàìí³ äîêóìåíòè:

- Ñïåöèô³êàö³ÿ;

- Òåõí³÷íå çàâäàííÿ;

- Ïîÿñíþâàëüíà çàïèñêà;

- Ïðîãðàìà òà ìåòîäèêà ³ñïèòó;

- Òåêñò ïðîãðàìè.

̲ͲÑÒÅÐÑÒÂÎ ÎѲÒÈ ² ÍÀÓÊÈ ÓÊÐÀ¯ÍÈ

ÍÀÖ²ÎÍÀËÜÍÈÉ ÒÅÕͲ×ÍÈÉ ÓͲÂÅÐÑÈÒÅÒ

"ÕÀÐʲÂÑÜÊÈÉ ÏÎ˲ÒÅÕͲ×ÍÈÉ ²ÍÑÒÈÒÓÒ

Êàôåäðà Îá÷èñëþâàëüíî¿ òåõí³êè òà ïðîãðàìóâàííÿ

ÇÀÒÂÅÐÄÆÓÞ

Çàâ³äóâà÷ êàôåäðè ÎÒÏ

__________ /Xxxxxxxxxxx./

"___" __________ 2007ð.

Ðîçðàõóíêîâî-ãðàô³÷íå çàâäàííÿ ¹ 1, 2

²ÍÔÎÐÌÀÖ²ÉÍÎ-ÄβÄÊÎÂÀ ÑÈÑÒÅÌÀ

Ïîÿñíþâàëüíà çàïèñêà

ËÈÑÒ ÇÀÒÂÅÐÄÆÅÍÍß

Xxxxxxxxxxx-01 81 01-1-ËÇ

Ðîçðîáíèêè

Êåð³âíèê ïðîåêòó

__________ /äîö. Xxxxxxxxxxx./

"___" __________ 2007 ð.

Âèêîíàâåöü

__________ /ñòóä. Xxxxxxxxxxx./

"___" __________ 2007 ð.

2007
Àíîòàö³ÿ

Ó äàíîìó ðîçðàõóíêîâî-ãðàô³÷íîìó çàâäàíí³ äîêëàäíî ðîçãëÿäàºòüñÿ àëãîðèòìè ïîë³ìîðôíèõ ñïèñê³â îá’ºêò³â, ðîçðîáëåíà ïðîãðàìà, ùî ðåàë³çóº àëãîðèòì ïîë³ìîðôíèõ ñïèñê³â îá’ºêò³â òà ³íòåðôåéñíà ÷àñòèíà ïðîãðàìè ìîâîþ C++.

Ïîÿñíþâàëüíà çàïèñêà ì³ñòèòü äîñòàòíüî ïðèêëàä³â òà òåîðåòè÷íó ÷àñòèíó äëÿ ñàìîñò³éíîãî ðîçãëÿäó òà îïàíóâàííÿ òåìè «Ïîë³ìîðôí³ ñïèñêè îá’ºêò³â».


Àííîòàöèÿ

 äàííîì ðàñ÷åòíî-ãðàôè÷åñêîì çàäàíèè ïîäðîáíî ðàññìàòðèâàåòñÿ àëãîðèòìû ïîëèìîðôíûõ ñïèñêîâ îáúåêòîâ, ðàçðàáîòàííàÿ ïðîãðàììà, êîòîðàÿ ðåàëèçóåò àëãîðèòì ïîëèìîðôíûõ ñïèñêîâ îáúåêòîâ è èíòåðôåéñíàÿ ÷àñòü ïðîãðàììû ÿçûêîì C++.

Îáúÿñíèòåëüíàÿ çàïèñêà ñîäåðæèò äîñòàòî÷íî ïðèìåðîâ è òåîðåòè÷åñêóþ ÷àñòü äëÿ ñàìîñòîÿòåëüíîãî ðàññìîòðåíèÿ è îâëàäåíèå òåìû «Ïîëèìîðôíûå ñïèñêè îáúåêòîâ».


Annotation

In the given settlement-graphic task in details is described algorithms of polymorphic lists of the objects, the developed program which realizes algorithm of polymorphic lists of objects and the interface part of the program language C++.

The explain annotation contains enough examples and a theoretical part for independent consideration and mastering of a theme « polymorphic lists of objects».

Çì³ñò

1.         Âñòóï

2.         Ïðèçíà÷åííÿ

3.         Òåõí³÷í õàðàêòåðèñòèêè

4.         Îòðèìàí ðåçóëüòàòè

5.         Ñïèñîê âèêîðèñòàíî¿ ë³òåðàòóðè

Ñ++ - öå ñïðîáà ð³øåííÿ ðîçðîáëþâà÷àìè ìîâè Ñ çàâäàíü îᢺêòíî- îð³ºíòîâàíîãî ïðîãðàìóâàííÿ (Object Oriented Programming, OOP). Ïîáóäîâàíèé íà òâåðäîìó ôóíäàìåíò³ Ñ, Ñ++ êð³ì ÎÎÐ ï³äòðèìóº áåçë³÷ ³íøèõ êîðèñíèõ ³íñòðóìåíò³â, í³ æåðòâóþ÷è ïðè öüîìó í³ ì³ööþ, í³ åëåãàíòí³ñòþ, í³ ãíó÷ê³ñòþ Ñ. Ñ++ ñòàâ óí³âåðñàëüíîþ ìîâîþ äëÿ ïðîãðàì³ñò³â óñüîãî ìèðó. Ñàìå íà ìîâ³ Ñ++ ïðîâîäèòüñÿ íàâ÷àííÿ ñòóäåíò³â ó âóçàõ âèùèõ íàâ÷àëüíèõ çàêëàä³â äëÿ ï³äãîòîâêè ïîäàëüøî¿ áàçè äëÿ ãàðíîãî ïðàöåâëàøòóâàííÿ. Ñ++ ì³ñòèòü çðó÷íèé ³íòåðôåéñ äëÿ êîðèñòóâà÷à ïî÷àòê³âöÿ äëÿ ðîçðîáêè ïðîñò³øèõ çàäà÷ àëå ìຠòàêîæ ³ ìîæëèâîñò³ äëÿ ðîçðîáêè ñêëàäíèõ ïðîãðàì.

Ó äàí³é ðîáîò øèðîêî âèêîðèñòîâóºòüñÿ ïîë³ìîðô³çì òà äâîíàïðÿìëåíèé ñïèñîê êëàñ³â.

1.         Ïðèçíà÷åííÿ òà îáëàñòü âèêîðèñòàííÿ

Ïðèçíà÷åííÿ äàíî ïðîãðàìè – çáåðåæåííÿ ³íôîðìàö³¿ î ìóçè÷íèõ àëüáîìàõ: íàçâà, ð³ê âèïóñêó, ê³ëüê³ñòü òðåê³â, ê³ëüê³ñòü áîíóñíèõ òðåê³â òà äîâãîòè çâó÷àííÿ.

Ðîçðîáëåíà ïðîãðàìà ïîâèííà âèêîíóâàòè:

-      Ñòâîðåííÿ ïîë³ìîðôíîãî ñïèñêó îá’ºêò³â;

-      Âèâ³ä éîãî íà åêðàí;

-      Çàíåñåííÿ ó ôàéë;

-      Ç÷èòóâàííÿ ç ôàéëó;

-      Ïîøóê çàïèñó;

-      Ðåäàãóâàííÿ çàïèñó;

-      Âñòàâêà íîâîãî çàïèñó;

-      Çíèùåííÿ çàïèñó;

-      Çíàõîäæåííÿ çàïèñó íàéìåíøîþ ê³ëüê³ñòþ òðåê³â ó çàäàíîìó ä³àïàçîí³ ðîê³â

-      Âèõ³ä.

Âèêîðèñòîâóâàòè äàíó ïðîãðàìó ìîæíà äëÿ âèâ÷åííÿ ïðèíöèïó ðîáîòè ç³ ïîë³ìîðô³çìîì òà ñïèñêîì.

Ïðè ðîáîò³ ç ñïèñêàìè íà ïðàêòèö³ ÷àñò³øå óñüîãî ïðèõîäèòüñÿ âèêîíóâàòè íàñòóïí³ îïåðàö³¿:

-           çíàéòè åëåìåíò ç çàäàíèìè âëàñòèâîñòÿìè;

-           çíàéòè ïåðøèé åëåìåíò ó ë³í³éíîìó ñïèñêó;

-           âñòàâèòè åëåìåíò äî òà ï³ñëÿ âêàçàíîãî âóçëà;

-           âèäàëèòè êîíêðåòíèé åëåìåíò ³ç ñïèñêó;

-           óïîðÿäêóâàòè âóçëè ñïèñêó ó êîíêðåòíîìó ïîðÿäêó.

2.         Òåõí³÷í õàðàêòåðèñòèêè

Ôóíêö³îíóâàííÿ ñèñòåìè ö³ëêîì çàáåçïå÷óºòüñÿ ñòàíäàðòíîþ êîíô³ãóðàö³ºþ IBM ñóì³ñíèõ ïåðñîíàëüíèõ ÅÎÌ. Äëÿ åêñïëóàòàö³¿ ñèñòåìè íåîáõ³äíèé IBM/PC AT ç CPU òèïó k286 ÷è âèùå, îáñÿãîì îïåðàòèâíî¿ ïàì'ÿò³ 4 Ìáàéò ³ íàêîïè÷óâà÷åì íà HARD äèñêó îáñÿãîì íå ìåíø 200 Ìáàéò.

Ùî ñòîñóºòüñÿ äàíî¿ ïðîãðàìè, òî âõ³äíèìè äàíèìè º ³íôîðìàö³ÿ òèïó int òà char. Âèõ³äí³ äàí òèïàìè öèõ æå òèï³â. Îñíîâí³ ôóíêö³¿ âñòàíîâëþþòü ³íôîðìàö³þ àáî âèâîäÿòü íà åêðàí.

Íèæ÷å ïðèâåäåí ñõåìè àëãîðèòìó ãîëîâíî¿ ôóíêö³¿ void main().(Äèâèñü ìàëþíîê 1.1)


3.         Î÷³êóâàí òåõí³êî-åêîíîì³÷í³ ïîêàçíèêè

Äàíà ïðîãðàìà çàéìຠì³í³ìàëüíèé îá’ºì ïàì’ÿò³. Ïîøèðåíà ³íôîðìàö³ÿ ùîäî âèìîã çàçíà÷åíà âèùå. Åêîíîì³÷í³ ïðèáóòêè íå ðîçãëÿäàþòüñÿ, îñê³ëüêè äàíà ïðîãðàìà º îá’ºêòîì äëÿ íàâ÷àííÿ. ª ìîæëèâ³ñòü ùîäî âèêîðèñòàííÿ ¿¿ ÿê ïîñ³áíèêà äëÿ íàñòóïíèõ êóðñ³â.

4.         Ðîçðîáêà

Ó ïðîãðàì³ âèêîðèñòîâóºòüñÿ ïîë³ìîðô³çì, ³íêàïñóëÿö³ÿ òà óñïàäêóâàííÿ, ÿñêðàâî ïðåäñòàâëåíî ÎÎÏ. Ïðè çâåðíåí³ äî áàòüê³âñüêîãî êëàñó, âèêëèêàþòüñÿ ôóíêö³¿ íàñë³äíèõ êëàñ³â(ïîë³ìîðô³çì).Ïðè óñïàäêóâàíí³ íàñë³äí³ êëàñè ìàþòü äîñòóï äî ïîë³â áàòüê³âñüêîãî êëàñó. Âèêîðèñòàíî â³ðòóàëüí³ ôóíêö³¿ òà ïîë³ìîðôíèé ñïèñîê îá’ºêò³â.

²íêàïñóëÿö³ÿ äîçâîëÿº «çàõîâàòè» çì³íí³-åëåìåíòè êëàñó.

Îïèñ êëàñ³â

album

Çì³ííà Ïðèçíà÷åííÿ Ìåòîäè Ïðèçíà÷åííÿ

Nazv

God

Íàçâà àëüáîìó

гê âèïóñêó

virtual void input()

virtual void output()

Âîä òà âèâîä íôîðìàö³¿

àlbum1

Çì³ííà Ïðèçíà÷åííÿ Ìåòîäè Ïðèçíà÷åííÿ
Trek ʳëüê³ñòü òðåê³â

--//--

int getTrek()

void setTrek()

--//--

Âñòàíîâëåííÿ çíà÷åííÿ trek

àlbum

Çì³ííà Ïðèçíà÷åííÿ Ìåòîäè Ïðèçíà÷åííÿ
Time Ïðîòÿæí³ñòü çà ÷àñîì

--//--

int getTime()

void setTime()

--//--

Âñòàíîâëåííÿ çíà÷åííÿ time

album3

Çì³ííà Ïðèçíà÷åííÿ Ìåòîäè Ïðèçíà÷åííÿ
Bonus ʳëüê³ñòü áîíóñíèõ òðåê³â

--//--

Int getBonus(), void setBonus()

--//--

Âñòàíîâëåííÿ çíà÷åííÿ bonus

Tool

Çì³ííà Ïðèçíà÷åííÿ Ìåòîäè Ïðèçíà÷åííÿ

T

*d

*right

*left

Çì³ííà ñïèñêó

Óêàç. íà îá’ºêò

Óêàç. íà îá’ºêò->

Óêàç. íà îá’ºêò<-

Trst

Çì³ííà Ïðèçíà÷åííÿ Ìåòîäè Ïðèçíà÷åííÿ

*head

*tail

*current

Óêàç. íà ãîëîâó

Óêàç. íà õâ³ñò

Óêàç. íà òåêóù³é

Void add(int type, int vvod) Äîäàâííà íîâèõ åëåìåíò³â ñïèñêó

Êëàñ àlbum – öå áàçîâèé (áàòüê³âñüêèé) êëàñ, ùî ì³ñòèòü äâà ³íôîðìàö³éíèõ ïîëÿ: íàçâó àëüáîìó (ñòðîêîâèé òèï) òà ð³ê âèïóñêó (ö³ëî÷èñëîâèé òèï). ³í ìຠäâ³ â³ðòóàëüí³ ôóíêö (ââîäó/âèâîäó), òà êîíñòðóêòîð ç äåñòðóêòîðîì.

Êëàñ àlbum1 – öå êëàñ-íàùàäîê êëàñó àlbum, â³í ì³ñòèòü ³íôîðìàö³éíå ïîëå, ùî íåñå ³íôîðìàö³þ î ê³ëüêîñò³ òðåê³â ó àëüáîì³. ³í òàêîæ ìຠâ³ðòóàëüí³ ôóíêö³¿ (ââîäó/âèâîäó) òà êîíñòðóêòîð ç äåñòðóêòîðîì, àëå ùå â³í ìຠäâ³ ôóíêö³¿ ùî ñòâîðþþòü ïîëå trek, òà ïîâåðòàþòü çíà÷åííÿ öüîãî ïîëÿ.

Êëàñ àlbum2 – öå êëàñ-íàùàäîê êëàñó àlbum1, â³í ì³ñòèòü ³íôîðìàö³éíå ïîëå, ùî íåñå ³íôîðìàö³þ î ïðîòÿæíîñò³ àëüáîìó çà ÷àñîì. ³í òàêîæ ìຠâ³ðòóàëüí³ ôóíêö³¿ (ââîäó/âèâîäó) òà êîíñòðóêòîð ç äåñòðóêòîðîì, àëå ùå â³í ìຠäâ³ ôóíêö³¿ ùî ñòâîðþþòü ïîëå time, òà ïîâåðòàþòü çíà÷åííÿ öüîãî ïîëÿ.

Êëàñ àlbum3 – öå êëàñ-íàùàäîê êëàñó àlbum2, â³í ì³ñòèòü ³íôîðìàö³éíå ïîëå, ùî íåñå ³íôîðìàö³þ î ê³ëüêîñò³ áîíóñíèõ òðåê³â ó àëüáîì³. ³í òàêîæ ìຠâ³ðòóàëüí³ ôóíêö (ââîäó/âèâîäó) òà êîíñòðóêòîð ç äåñòðóêòîðîì, àëå ùå â³í ìຠäâ³ ôóíêö³¿ ùî ñòâîðþþòü ïîëå bonus, òà ïîâåðòàþòü çíà÷åííÿ öüîãî ïîëÿ.

Êëàñ Tool – öå êëàñ ÿêèé º äâîíàïðÿìëåíèì ñïèñêîì îá’ºêò³â êëàñó àlbum òà éîãî íàùàäê³â. Ôóíêö³ÿìè äàíîãî êëàñó êîíñòðóêòîð òà äåñòðóêòîð ùî â³äïîâ³äíî ñòâîðþþòü ïîë³ìîðôíèé ñïèñîê îá’ºêò³â òà âèâ³ëüíÿþòü ïàì'ÿòü â³äâåäåíó ï³ä íüîãî.

Êëàñ Trist º äðóæí³ì äî êëàñó Tool.³í âì³ùຠôóíêö³þ äîäàâàííÿ íîâèõ îá’ºêò³â äî ñïèñêó. Íîâ³ îá’ºêòè äîäàþòüñÿ ó ê³íåöü(õâ³ñò) ñïèñêó ³ ìîæóòü áóòè îäíîãî ç òèï³â àlbum, àlbum1, àlbum2 òà àlbum3.

Ôóíêö³ÿ int get….() ïîâåðòຠçíà÷åííÿ äàíîãî ïîëÿ äëÿ îá’ºêòó.

Ôóíêö³ÿ int set….() ñòâîðþº ïîëå îá'ºêòà à ñàìå âñòàíîâëþº â³äïîâ³äí³ñòü(çàíîñèòü ó ïîëå ³íôîðìàö³þ) ç ³íôîðìàö³ºþ ùî ââîäèòü êîðèñòóâà÷ ïðè çàïîâíåí³ òàáëèö³.

Ôóíêö³¿ virtual void output() òà virtual void input() ÿâëÿþòüñÿ ÿñêðàâèìè ïîêàæ÷èêàìè ïîë³ìîðô³çìó áî º â³ðòóàëüíèìè ôóíêö³ÿìè. Âîíè ñëóãóþòü äëÿ âèâîäó íà åêðàí àáî çàïîâíåííÿ îá’ºêòó ïðè ðîáîò³ ç òàáëèöåþ.

6.         Ñïèñîê âèêîðèñòàíî¿ ë³òåðàòóðè

·          Øèëäò Ã. Ñàìîó÷èòåëü Ñ++. – Ñàíêò-Ïåòåðáóðã, 2007.

·          Ìàòåð³àëè ëîêàëüíî¿ ñ³òêè ÍÒÓ "Õϲ".

̲ͲÑÒÅÐÑÒÂÎ ÎѲÒÈ ² ÍÀÓÊÈ ÓÊÐÀ¯ÍÈ

ÍÀÖ²ÎÍÀËÜÍÈÉ ÒÅÕͲ×ÍÈÉ ÓͲÂÅÐÑÈÒÅÒ

"ÕÀÐʲÂÑÜÊÈÉ ÏÎ˲ÒÅÕͲ×ÍÈÉ ²ÍÑÒÈÒÓÒ

Êàôåäðà Îá÷èñëþâàëüíî¿ òåõí³êè òà ïðîãðàìóâàííÿ

ÇÀÒÂÅÐÄÆÓÞ

Çàâ³äóâà÷ êàôåäðè ÎÒÏ

__________ /Xxxxxxxxxxx./

"___" __________ 2007ð.

Ðîçðàõóíêîâî-ãðàô³÷íå çàâäàííÿ ¹ 1, 2

²ÍÔÎÐÌÀÖ²ÉÍÎ-ÄβÄÊÎÂÀ ÑÈÑÒÅÌÀ

Ïðîãðàìà òà ìåòîäèêà ³ñïèò³â

ËÈÑÒ ÇÀÒÂÅÐÄÆÅÍÍß

Xxxxxxxxxxx-01 51 01-1-ËÇ

Ðîçðîáíèêè

Êåð³âíèê ïðîåêòó

__________ /äîö. Xxxxxxxxxxx./

"___" __________ 2007 ð.

Âèêîíàâåöü

__________ /ñòóä. Xxxxxxxxxxx./

"___" __________ 2007 ð.

2007
ÓÇÃÎÄÆÅÍÎ

Xxxxxxxxxxx-01 51 01-1-ËÇ


Ðîçðàõóíêîâî-ãðàô³÷íå çàâäàííÿ ¹ 1, 2

²ÍÔÎÐÌÀÖ²ÉÍÎ-ÄβÄÊÎÂÀ ÑÈÑÒÅÌÀ

Ïðîãðàìà òà ìåòîäèêà ³ñïèò³â

Xxxxxxxxxxx-01 51 01-1

2007


1.         Îá’ºêò ³ñïèò³â

Ïðîãðàìà ÿâëÿº ñîáîþ ìîäóëü, ùî ñêëàäàºòüñÿ ç òðüîõ ôàéë³â:

-           RGZ.cpp (Îñíîâíèé ôàéë, ì³ñòèòü ôóíêö³þ main( ) );

-           RGZ_DSC.cpp (Ôàéë, ùî ì³ñòèòü îïèñ ôóíêö³é êëàñ³â) ;

-           RGZ.Í (Ôàéë, ùî ì³ñòèòü îïèñ êëàñ³â)

Îá’ºêòîì ³ñïèò³â º íèæ÷å ïðèâåäåíà ïðîãðàìà.

2.         Ìåòà ³ñïèò³â

Ìåòà ³ñïèò³â – öå âïåâíèòèñÿ ó ïðàâèëüíîñò³ ðîáîòè äàíî¿ ïðîãðàìè òà îö³íèòè ¿¿ åôåêòèâí³ñòü.

Òåñòè, êîòð ïåðåâ³ðþþòü ïðàâèëüí³ñòü ðîáîòè ïðîãðàìè ïðèâåäåí³ ó ïóíêò³ «Çàñîáè òà ïîðÿäîê âèïðîáóâàíü».

3.         Âèìîãè äî ïðîãðàìè òà ïðîãðàìíîãî äîêóìåíòà

Ôóíêö³îíóâàííÿ ñèñòåìè ö³ëêîì çàáåçïå÷óºòüñÿ ñòàíäàðòíîþ êîíô³ãóðàö³ºþ IBM ñóì³ñíèõ ïåðñîíàëüíèõ ÅÎÌ.

Îñíîâíà âèìîãà äî ïðîãðàìè – öå ÷³òêå äåìîíñòðóâàííÿ ïîë³ìîðô³çìó òà ïðàâèëüí³ñòü ðîáîòè, à òàêîæ, âò³ëåííÿ îñíîâíî¿ çàäà÷³.

4.         Çàñîáè òà ïîðÿäîê ñïèò³â

Çàñîáîì ³ñïèò³â ââåäåííÿ ³íôîðìàö³¿ çà ï³äêàçêàìè, ÿê³ ç’ÿâëÿþòüñÿ ó ïðîöåñ³ ðîáîòè ïðîãðàìè. Øëÿõîì ïîð³âíÿííÿ ôàêòè÷íîãî ðåçóëüòàòó ðîáîòè ïðîãðàìè ç ïðîãíîçîâàíèìè ðåçóëüòàòàìè, âñòàíîâëþºòüñÿ â³ðí³ñòü ðîáîòè ïðîãðàìè.

Ðîçãëÿíåìî âèêîíàííÿ ïðîãðàìè ïî ïóíêòàõ:

·          Ïåðåä êîðèñòóâà÷åì ç'ÿâëÿºòüñÿ ïîâ³äîìëåííÿ: "Vvedite nomer operatsii".

·          ßêùî âè íàòèñíåòå êëàâ³øó "1", òî âèêîíàºòå íàñòóïí³ ä³¿:

Sozdanie tablizi dannih

Vvedite N: 3

Vvedite tip zapisi [0..2]: 2

Vvedite nazvanie alboma: qqq

Vvedite god vipuska: 1889

Vvedite kl-vo trekov v albome: 11

Vvedite prodolzitelnost alboma po vremeni: 60

Vvedite kolichestvo bonus trekov: 2

Vvedite tip zapisi [0..2]: 0

Vvedite nazvanie alboma: www

Vvedite god vipuska: 1990

Vvedite kl-vo trekov v albome: 12

Vvedite tip zapisi [0..2]: 1

Vvedite nazvanie alboma: eee

Vvedite god vipuska: 1991

Vvedite kl-vo trekov v albome: 13

Vvedite prodolzitelnost alboma po vremeni: 58

·          Ïðè íàòèñêàíí³ íà êëàâ³øó "2" íà åêðàí³ ç'ÿâèòüñÿ òàáëèöÿ ÿêó âè çàïîâíèëè âèùå:

Vivod na ekran

|Nazv |God |Treki |Vremya |Bonus+

-------------------------------------------------------

qqq 1889 11 60 2

www 1990 12

eee 1991 13 58

 Vivod na ekran zavershen.

·          ßêùî âè íàòèñíåòå "3", òî íà åêðàí³ ç'ÿâèòüñÿ ïîâ³äîìëåííÿ:

Vvedite nomer operatsii:3

Vivod v fail a.dat

Vivod v fail uspeshno zavershen.

·          ßêùî âè íàòèñíåòå "4", òî íà åêðàí³ ç'ÿâèòüñÿ ïîâ³äîìëåííÿ:

Vvedite nomer operatsii:4

Chtenie iz faila a.dat

Chtenie iz faila uspeshno zavershena.

·          Ïðè íàòèñêàíí³ íà êëàâ³øó "5" íà åêðàí³ ç'ÿâèòüñÿ ïîâ³äîìëåííÿ òà âè âèêîíàºòå íàñòóïí³ ä³¿:

Vvedite nomer operatsii:5

Poisk obyekta

Vvedite kluch dlya poiska(nazvanie alboma): www

Zapis bila naidena.

|Nazv |God |Treki |Vremya |Bonus+

-------------------------------------------------------

www 1990 12

·          ßêùî âè íàòèñíåòå "6", òî íà åêðàí³ ç'ÿâèòüñÿ ïîâ³äîìëåííÿ òà âè âèêîíàºòå íàñòóïí 䳿:

Vvedite nomer operatsii:6

Redaktirovanie zapisi

Vvedite nomer zapisi: 2

vedite nazvanie alboma: rrr

vedite god vipuska: 1234

vedite kl-vo trekov v albome: 13

vedite prodolzitelnost alboma po vremeni: 56

 Redaktirovanie uspeshno zaversheno.

·          Ðåçóëüòàòîì âàøèõ ä³é áóäå òå, ùî îäèí çàïèñ ó òàáëèö³ çì³íèòüñÿ:

Vivod na ekran

|Nazv |God |Treki |Vremya |Bonus+

-------------------------------------------------------

qqq 1889 11 60 2

www 1990 12

rrr 1234 13 56

Vivod na ekran zavershen.

·          Ïðè íàòèñêàíí³ íà êëàâ³øó "7" íà åêðàí³ ç'ÿâèòüñÿ ïîâ³äîìëåííÿ òà âè âèêîíàºòå íàñòóïí³ ä³¿:

Vvedite nomer operatsii:7

Vstavka novoi zapisi

Vvedite tip novoy zapisi [0..2]: 2

vedite nazvanie alboma: zzz

vedite god vipuska: 1534

Vvedite kl-vo trekov v albome: 13

Vvedite prodolzitelnost alboma po vremeni: 222

Vvedite kolichestvo bonus trekov: 1

Vstavka zapisi uspeshno zaversena.

·          Ðåçóëüòàòîì âàøèõ ä³é áóäå òå ùî îäèí çàïèñ ó òàáëèö³ çì³íèòüñÿ:

Vivod na ekran

|Nazv |God |Treki |Vremya |Bonus+

-------------------------------------------------------

qqq 1889 11 60 2

www 1990 12

rrr 1234 13 56

zzz 1534 11 222 1

 Vivod na ekran zavershen.

·          ßêùî âè íàòèñíåòå "8" òî íà åêðàí³ ç'ÿâèòüñÿ ïîâ³äîìëåííÿ òà âè âèêîíàºòå íàñòóïí³ ä³¿:

Vvedite nomer operatsii:8

Udalenie zapisi

Vvedite nomer zapisi dlya udalenia:1

Zapis bila udalena.

·          Ðåçóëüòàòîì âàøèõ ä³é áóäå òå, ùî îäèí çàïèñ ó òàáëèö³ áóäå çíèùåíî:

Vivod na ekran

|Nazv |God |Treki |Vremya |Bonus+

-------------------------------------------------------

qqq 1889 11 60 2

rrr 1234 13 56

zzz 1534 11 222 1

Vivod na ekran zavershen.

·          Ïðè íàòèñêàíí³ íà êëàâ³øó "9" íà åêðàí³ ç'ÿâèòüñÿ ïîâ³äîìëåííÿ òà âè âèêîíàºòå íàñòóïí³ ä³¿:

Vvedite nomer operatsii:9

Poisk obyekta s minimalnim kl-vom trekov v zadannom diapazone let

Vvedite leviy predel poiska(god): 1

Vvedite praviy predel poiska(god): 1600

Zapis bila naidena.

|Nazv |God |Treki |Vremya |Bonus+

-------------------------------------------------------

zzz 1534 11 222 1

·          Ïðè íàòèñêàíí³ íà êëàâ³øó "10" ïðîãðàìó áóäå çàâåðøåíî.

Êîæíèé îòðèìàíèé ðåçóëüòàò â³äïîâ³äà ïîñòàâëåí³é çàäà÷³.

Îòðèìàíí³ ðåçóëüòàòè çá³ãàþòüñÿ ç ïðîãíîçàìè, ùîäî â³ðíîñò³ ðîáîòè äàíî¿ ïðîãðàìè, òîáòî çàäà÷à âèêîíàíà â³ðíî.

̲ͲÑÒÅÐÑÒÂÎ ÎѲÒÈ ² ÍÀÓÊÈ ÓÊÐÀ¯ÍÈ

ÍÀÖ²ÎÍÀËÜÍÈÉ ÒÅÕͲ×ÍÈÉ ÓͲÂÅÐÑÈÒÅÒ

"ÕÀÐʲÂÑÜÊÈÉ ÏÎ˲ÒÅÕͲ×ÍÈÉ ²ÍÑÒÈÒÓÒ

Êàôåäðà Îá÷èñëþâàëüíî¿ òåõí³êè òà ïðîãðàìóâàííÿ

ÇÀÒÂÅÐÄÆÓÞ

Çàâ³äóâà÷ êàôåäðè ÎÒÏ

__________ /Xxxxxxxxxxx./

"___" __________ 2007ð.

Ðîçðàõóíêîâî-ãðàô³÷íå çàâäàííÿ ¹ 1, 2

²ÍÔÎÐÌÀÖ²ÉÍÎ-ÄβÄÊÎÂÀ ÑÈÑÒÅÌÀ

Òåêñò ïðîãðàìè

Xxxxxxxxxxx-01 12 01-1-ËÇ

Ðîçðîáíèêè

Êåð³âíèê ïðîåêòó

__________ /äîö. Xxxxxxxxxxx./

"___" __________ 2007 ð.

Âèêîíàâåöü

__________ /ñòóä. Xxxxxxxxxxx./

"___" __________ 2007 ð.

2007
ÓÇÃÎÄÆÅÍÎ

Xxxxxxxxxxx-01 81 01-1-ËÇ

Ðîçðàõóíêîâî-ãðàô³÷íå çàâäàííÿ ¹ 1, 2

²ÍÔÎÐÌÀÖ²ÉÍÎ-ÄβÄÊÎÂÀ ÑÈÑÒÅÌÀ

Òåêñò ïðîãðàìè

Xxxxxxxxxxx-01 12 01-1

2007

Òåêñò ïðîãðàìè

//Çàãîëîâêîâèé ôàéë

#include <string.h>

class album

         {

                   public:

                            album() {}

                            virtual void input();

                            virtual void output();

                            char nazv[4];//Íàçâà

                            int god;//гê âèïóñêó

                            ~album() {}

         };

class album1: public album

         {        protected:

                            int trek;//ʳëüê³ñòü òðåê³â

                   public:

                            album1();

                            virtual void input();

                            virtual void output();

                            int getTrek()

                            {

                                      return trek;

                            }

                            void setTrek(int c)//ô-ö³ÿ ñòâîðåííÿ ïîëÿ

                            {

                                      trek=c;

                            }

                            ~album1();

         };

class album2: public album1

         {

                   protected:

                            int time;//×àñ çâó÷àííÿ

                   public:

                            album2();

                            virtual void input();

                            virtual void output();

                            int getTime()

                            {

                                      return time;

                            }

                            void setTime(int c)

                            {

                                      time=c;

                            }

                            ~album2();

         };

class album3: public album2

         {

                   protected:

                            int bonus;//ʳëüê³ñòü áîíóñ òðåê³â

                   public:

                            album3();

                            virtual void input();

                            virtual void output();

                            int getBonus()

                            {

                                      return bonus;

                            }

                            void setBonus(int c)

                            {

                                      bonus=c;

                            }

                            ~album3();

         };

class Tool

         {

                   public:

                            album *d;

                            int t;

                            friend class Trist;//îá'ÿâëåííÿ äðóæíüîãî êëàñó

                            Tool *right,*left;

         };

class Trist

         {

                   public:

                            Tool *head,*tail;

                            Tool *current;

                            Trist(int type,int vvod);//Êîíñòðóêòîð

                            void add(int type, int vvod);//ô_ö³ÿ äîáàâëåííÿ îá’ºêò³â

                            ~Trist();//Äåñòðóêòîð

         };

//Îïèñíèé ôàéë

#include "RGZ.h"

#include <iostream.h>

#include <string.h>

#include <stdlib.h>

#include <iomanip.h>

void album::input()//ô-ö³ÿ ââîäó

{

         cout << "Vvedite nazvanie alboma: ";

         cin >> nazv;

         nazv[3]=NULL;

         cout << "Vvedite god vipuska: ";

         cin >> god;

}

void album::output()//ô-ö³ÿ âèâîäó

{

 cout << endl<< setw(10) << setiosflags(ios::left) << nazv

          << setw(10) << setiosflags(ios::left) << god;

}

album1::album1():album() {}//êîíñòðóêòîð

album1::~album1(){ album::~album(); }//äåñòðóêòîð

void album1::input()

{

         album::input();

         cout << "Vvedite kl-vo trekov v albome: ";

         cin >> trek;

}

void album1::output()

{

         album::output();

         cout<< setw(10) << setiosflags(ios::left) << trek;

}

album2::album2():album1() {}

album2::~album2() { album1::~album1(); }

void album2::input()

{

         album1::input();

         cout << "Vvedite prodolzitelnost alboma po vremeni: ";

         cin >> time;

}

void album2::output()

{

         album1::output();

         cout << setw(12) << setiosflags(ios::left) << time;

}

album3::album3():album2() {}

album3::~album3() { album2::~album2(); }

void album3::input()

{

         album2::input();

         cout << "Vvedite kolichestvo bonus trekov: ";

         cin >> bonus;

}

void album3::output()

{

         album2::output();

         cout << setw(10) << setiosflags(ios::left) << bonus;

}

void caption()//çàãîëîâêîâà ô-ö³ÿ

setw(10) << setiosflags(ios::left) << "

Trist::Trist(int type, int vvod)//Ñòâîðåííÿ ñïèñêó îá'ºêò³â

{

         album1 *pr;

         album2 *sp;

         album3 *fl;

         head = new Tool;

         head->t = type;

         if (head->t == 0)

         {

                   pr = new album1;

                   if (vvod)

                            pr->input();

                   head->d=pr;

         } else

         if (head->t == 1)

         {

                   sp = new album2;

                   if (vvod)

                            sp->input();

                   head->d=sp;

         } else

         if (head->t == 2)

         {

                   fl = new album3;

                   if (vvod)

                            fl->input();

                   head->d=fl;

         }

         head->right=NULL;

         head->left=NULL;

         tail=head;

         current=head;

}

Trist::~Trist()//Âèñâîáîäæåííÿ ïàìÿò³

{

         Tool *h;

         h=head;

         while (h!=0)

         {        head=head->right;

                   head->left=NULL;

                   delete h;

                   h=head;

         }

}

void Trist::add(int type, int vvod)//äîäàâàííÿ íîâîãî îá’ºêòà ó ñïèñîê

{

         Tool *q = new Tool;

         album1 *pr;

         album2 *sp;

         album3 *fl;

         q->t = type;

         switch (q->t)

         {

                   case 0:

                            pr = new album1;

                            if (vvod)

                                      pr->input();

                            q->d=pr;

                            break;

                   case 1:

                            sp=new album2;

                            if (vvod)

                                      sp->input();

                            q->d=sp;

                            break;

                   case 2:

                            fl=new album3;

                            if (vvod)

                                      fl->input();

                            q->d=fl;

                            break;

         }

         if (current==tail)

         {

                   q->right=NULL;

                   q->left=current;

                   current->right=q;

                   tail=q;

                   current=q;

         } else

         {        q->right=current->right;

                   current->right->left=q;

                   current->right=q;

                   q->left=current;

                   current=q;

         }

}

//Ãîëîâíèé ôàéë

#include "RGZ_dsc.cpp"

#include <iostream.h>

#include <conio.h>

#include <stdlib.h>

#include <fstream.h>

void sozdan(Trist *&a, int n);//ñòâîðåííÿ

void output(Trist *&a);//âèâ³ä íà åêðàí

void output_file(Trist *&a, int n);//âèâ³ä äî ôàéëó

void input_file(Trist *&a);//÷èòàííÿ ç ôàéëó

Tool* pois(Trist *&a, char* nazv);//ô-ö³ÿ ïîøóêó

Tool* zadacha(Trist *&a,int godL,int godR);//âèêîíàííÿ çàäà÷³

void main()//Ãîëîâíà ïðîãðàìà

{

         int i,N=5,k;

         Trist *a = NULL;

         clrscr();

         randomize();

         while (1)

         {

                   cout << "\n\n############################";

                   cout << "\n# 1 - Sozdanie bazi dannih #";

                   cout << "\n# 2 - Vivod na ekran #";

                   cout << "\n# 3 - Vivod v fail #";

                   cout << "\n# 4 - Chtenie iz faila #";

                   cout << "\n# 5 - Poisk #";

                   cout << "\n# 6 - Redaktirovanie zapisi #";

                   cout << "\n# 7 - Vstavka novoi zapisi #";

                   cout << "\n# 8 - Udalenie zapisi #";

                   cout << "\n# 9 - Vipolnrnie zadachi #";

                   cout << "\n# 10 - Vihod #";

                   cout << "\n\n############################";

                   cout << "\n Vvedite nomer operatsii:";

                   cin >> k;

                   switch (k)

                   {

                            case 1:

                                      cout << "\n Sozdanie tablizi dannih";

                                      cout << "\n Vvedite N: ";

                                      cin >> N;

                                      sozdan(a,N);

                                      cout << "\n Tabliza dannih sozdana.";

                                      getch();

                                      break;

                            case 2:

                                      cout << "\n Vivod na ekran ";

                                      output(a);

                                      cout << "\n Vivod na ekran zavershen.";

                                      getch();

                                      break;

                            case 3:

                                      cout << "\n Vivod v fail a.dat ";

                                      output_file(a,N);

                                      cout << "\n Vivod v fail uspeshno zavershen.";

                                      getch();

                                      break;

                            case 4:

                                      cout << "\n Chtenie iz faila a.dat ";

                                      input_file(a);

                                      cout << "\n Chtenie iz faila uspeshno zavershena.";

                                      getch();

                                      break;

                            case 5:

                                      cout << "\n Poisk obyekta ";

                                      cout << "\n Vvedite kluch dlya poiska(nazvanie alboma): ";

                                      char *nazv;

                                      cin >> nazv;

                                      Tool *n;

                             // n=NULL;

                                      n = pois(a,nazv);

                                      if (n==NULL) cout << "\n Zapis ne naidena.";

                                      else

                                      {

                                               cout << "\n Zapis bila naidena.";

                                               caption();

                                               n->d->output();

                                      }

                                      delete nazv;

                                      getch();

                                      break;

                            case 6:

                                      cout << "\n Redaktirovanie zapisi ";

                                      cout << "\n Vvedite nomer zapisi: ";

                                      int c;

                                      cin >> c;

                                      a->current=a->head;

                                      for (i=0;a->current!=NULL;i++)

                                      {

                                               if (i==c)

                                               {

                                                        a->current->d->input();

                                                        break;

                                               }

                                               a->current=a->current->right;

                                      }

                                      cout << "\n Redaktirovanie uspeshno zaversheno.";

                                      getch();

                                      break;

                            case 7:

                                      cout << "\n Vstavka novoi zapisi ";

                                      cout << "\n Vvedite tip novoy zapisi [0..2]: ";

                                      int p = 0;

                                      cin >> p;

                                      a->current=a->tail;

                                      a->add(p,1);

                                      cout << "\n Vstavka zapisi uspeshno zaversena.";

                                      getch();

                                      break;

                            case 8:

                                      cout << "\n Udalenie zapisi ";

                                      cout << "\n Vvedite nomer zapisi dlya udalenia: ";

                                      int j = 0;

                                      cin >> j;

                                      a->current=a->head;

                                      for (i=0;a->current!=NULL;i++)

                                      {

                                               if (i==j)

                                               {

                                                        Tool *q = a->current;

                                                        if (q->left!=NULL) q->left->right = q->right;

                                                        if (q->right!=NULL) q->right->left = q->left;

                                                        if (q==a->head) a->head=q->right;

                                                        if (q==a->tail) a->tail=q->left;

                                                        delete q;

                                                        a->current = a->tail;

                                                        break;

                                               }

                                               a->current=a->current->right;

                                      }

                                      cout << "\n Zapis bila udalena.";

                                      getch();

                                      break;

                            case 9:

                                      cout << "\n Poisk obyekta s minimalnim kl-vom trekov v zadannom diapazone let";

                                      cout << "\n Vvedite leviy predel poiska(god): ";

                                      int godL,godR;

                                      cin >> godL;

                                      cout << "\n Vvedite praviy predel poiska(god): ";

                                      cin >> godR;

                                      Tool *k;

                                      k = zadacha(a,godL,godR);

                                      if (n==NULL) cout << "\n Zapis ne naidena.";

                                      else

                                      {

                                               cout << "\n Zapis bila naidena.";

                                               caption();

                                               k->d->output();

                                      }

                                      getch();

                                      break;

                            case 10:

                                      delete a;

                                      exit(0);

                                      break;

                   }

}

}

void sozdan(Trist *&a, int n)

{

         if (a!=NULL)

                   delete a;

         cout << "\nVvedite tip zapisi [0..2]: ";

         int k;

         cin >> k;

         a = new Trist(k,1);

         for (int i=1;i<n;i++)

         {

                   cout << "\nVvedite tip zapisi [0..2]: ";

                   cin >> k;

                   a->add(k,1);

         }

}

void output(Trist *&a)

{

         caption();

         a->current=a->head;

         while (a->current!=NULL)

         {

                   a->current->d->output();

                   a->current=a->current->right;

         }

}

void output_file(Trist *&a, int n)

{

 ofstream file("a.dat",ios::out|ios::binary);

 if (!file)

 {

                   cerr << "\nOshibka vivoda v fail!\n";

                   getch();

                   exit(1);

 }

 file.seekp(0);

 file.write((char*)&(n),sizeof(n));

 a->current=a->head;

 while (a->current!=NULL)

 {

                   file.write((char*)&(a->current->t),sizeof(a->current->t));

                   file.write(a->current->d->nazv,sizeof(a->current->d->nazv));

                   switch (a->current->t)

                   {

                            case 0:

                                      album1 *obj1;

                                      obj1=(album1*)a->current->d;

                                      int trek = obj1->getTrek();

                                      file.write((char*)&(trek),sizeof(trek));

                                      break;

                            case 1:

                                      album2 *obj2;

                                      obj2=(album2*)a->current->d;

                                      trek = obj2->getTrek();

                                      int time = obj2->getTime();

                                      file.write((char*)&(trek),sizeof(trek));

                                      file.write((char*)&(time),sizeof(time));

                                      break;

                            case 2:

                                      album3 *obj3;

                                      obj3=(album3*)a->current->d;

                                      trek = obj3->getTrek();

                                      time = obj3->getTime();

                                      int bonus = obj3->getBonus();

                                      file.write((char*)&(trek),sizeof(trek));

                                      file.write((char*)&(time),sizeof(time));

                                      file.write((char*)&(bonus),sizeof(bonus));

                                      break;

                   }

                   a->current=a->current->right;

 }

 file.close();

}

void input_file(Trist *&a)

{

 ifstream file("a.dat",ios::in);

 if (!file)

 {

                   cerr << "\nOshibka chtenia faila!\n";

                   getch();

                   exit(1);

 }

 int n;

 file.read((char*)&(n),sizeof(n));

 int i;

 delete a;

 for (i=0;i<n;i++)

 {

                   int t;

                   file.read((char*)&(t),sizeof(t));

                   if (i==0) a=new Trist(t,0); else a->add(t,0);

                   file.read((char*)&(a->current->d->nazv),sizeof(a->current->d->nazv));

                   switch (t)

                   {

                            case 0:

                                      album1 *obj1;

                                      obj1=(album1*)a->current->d;

                                      int trek = 0;

                                      file.read((char*)&(trek),sizeof(trek));

                                      obj1->setTrek(trek);

                                      break;

                            case 1:

                                      album2 *obj2;

                                      obj2=(album2*)a->current->d;

                                      trek = 0;

                                      int time = 0;

                                      file.read((char*)&(trek),sizeof(trek));

                                      file.read((char*)&(time),sizeof(time));

                                      obj2->setTrek(trek);

                                      obj2->setTime(time);

                                      break;

                            case 2:

                                      album3 *obj3;

                                      obj3=(album3*)a->current->d;

                                      trek = 0;

                                      time = 0;

                                      int bonus = 0;

                                      file.read((char*)&(trek),sizeof(trek));

                                      file.read((char*)&(time),sizeof(time));

                                      file.read((char*)&(bonus),sizeof(bonus));

                                      obj3->setTrek(trek);

                                      obj3->setTime(time);

                                      obj3->setBonus(bonus);

                                      break;

                   }

 }

 file.close();

}

Tool* pois(Trist *&a, char* nazv)

{

         Tool *n = NULL;

         a->current=a->head;

         while (a->current!=NULL)

         {

                   n = a->current;

                   if (strcmp(n->d->nazv,nazv)==0) break;

                   else n=NULL;

                   a->current=a->current->right;

         }

         return n;

}

Tool* zadacha(Trist *&a,int godL,int godR)

{

         Tool *k = NULL;

         a->current=a->head;

         int max=1000;

         while (a->current!=NULL)

         {

                   k = a->current;

                   if(k->d->god>godL)

                    if(k->d->god<godR)

                    if(k->d->trek<min) break;

                    else k=NULL;

                   a->current=a->current->right;

         }

         return k;





© 2010 Èíòåðíåò Áàçà Ðåôåðàòîâ