Your SlideShare is downloading. ×
0
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Lecture914
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Lecture914

456

Published on

Published in: Technology, Art & Photos
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
456
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Ìýäýýëëèéí ñèñòåì, àëãîðèòìèéí ¿íäýñ Ëåêö ¹14
  • 2. Àãóóëãà 1. Äýä àëãîðèòì ôóíêö 2.Ôóíêö õýðýãëýõ 3. Õ¿ñíýãòýí àðãóìåíòòàé äýä àëãîðèòì
  • 3. Äýä àëãîðèòì-ôóíêö Èéìä àëãîðèòìûí õýëýíä ôóíêöèéã: Ôóíêö íýð (òºðºë_1 ïàðàìåòð_1,…,òºðºë_n ïàðàìåòð_n) áóö(áóöààõ_óòãà); Áèå ¿éëäë¿¿ä
  • 4. Ýíä áóöààõ_óòãà íü õóâüñàã÷ áîëîí äóðûí èëýðõèéëýë áàéæ áîëíî. Ôóíêö õýðýãëýõ Ìàòåìàòèê ôóíêöèéã èëýðõèéëýëä øóóä áè÷èæ àøèãëàäàã ó÷èð åðäèéí äýä àëãîðèòìààñ èë¿¿ òîõèðîìæòîé áàéäàã
  • 5. Æ1 : x, õýðýâ x  y max(x,y)= ôóíêöèéã àøèãëàí y, õýðýâ x<y ºãñºí a,b,c áîäèò óòãàíä
  • 6. Áîäîëò Àðã a,b,c; ¿ð ä¿í: t áîäèò:a,b,c,t; îðóóë(a,b,c); t:= t:=t/(1+ ãàðãà (t); òºãñ. ôóíêö max(x,y) õýðýâ y>x áîë x:=y áóö (x); max(a,b+c)+ Max(a,a+c): Max(a+b*c,3.1415));
  • 7. Äýä àëãîðèòìûã àøèãëàõ Àðãóìåíòèéí ºãñºí óòãàíä òîäîðõîé íýã óòãûã õàðãàëçóóëàí áîäîæ ºãäºã äýä àëãîðèòìûã ôóíêö õýëáýðòýé áè÷èõ íü èë¿¿ òîõèðîìæòîé.
  • 8. Ãýòýë áè÷èõ,óíøèõ,íýýõ,õààõ ã.ì òîäîðõîé ¿éëäýë áèåë¿¿ëýõ ýñâýë õýä õýäýí óòãà áîäîõîä çîðèóëñàí äýä àëãîðèòìûã äýä_àëã õýëáýðòýé ãîëöóó áè÷èæ øààðäëàãòàé ¿éëäëèéã ã¿éöýòãýõèéí òóëä õàðãàëçàõ äýä àëãîðèòìûã íýðýýð íü äóóäàæ òóñãàé íýã ¿éëäýë ìýò áè÷èæ àøèãëàäàã áàéíà.
  • 9. Ôóíêö çîõèîæ àøèãëàõ æèøýý 2.Íàòóðàë òîî n ºãºãäñºí áîë n,n+1,…,2n òîîíóóä äîòîð ÿëãàâàð íü 2-òîé òýíö¿¿ áàéõ àíõíû òîîíóóä áàéãàà ýñýõèéã øàëãà.
  • 10. Áîäîëò Íàò:n,k ; òåêñò s ; îðóóë(n); s:=‘áàéõã¿é’; K:=n,2*n-2 ¿åä_äàâò õýðýâ prime(k) and prime(k+2) áîë {ãàðãà(k,k+2);s:=‘áàéíà’} Ãàðãà(s) Òºãñ.
  • 11. Õ¿ñíýãòýí àðãóìåíòòàé äýä àëãîðèòì Íýã áîëîí îëîí õýìæýýñò õ¿ñíýãòèéã áîëîâñðóóëàõ ¿éëäýë ïðàêòèêò ò¿ãýýìýë øààðäàãääàã òóë ýäãýýð ¿éëäëèéã ã¿éöýòãýõ àëãîðèòìûã äýä àëãîðèòì áîëîí ôóíêö õýëáýðòýé áè÷èõ íü èë¿¿ òîõèðîìæòîé.
  • 12. Èéì òîõèîëäîëä äýä àëãîðèòìûí àðãóìåíò íü õ¿ñíýãò áàéõ ¸ñòîé. Äýä àëãîðèòìûí àðãóìåíòûí óòãûã ãëîáàëü õóâüñàã÷èéí òóñëàìæòàéãààð äàìæóóëàõ íü òîõèðîìæã¿é òóë äýä àëãîðèòì, ôóíêöèéã õèéñâýð àðãóìåíòòàé áè÷äýã.
  • 13. Õèéñâýð àðãóìåíòòàé õ¿ñíýãò áàéõ ¿åä: ò¿ëõ¿¿ð ¿ã õ¿ñíýãò ; ¿¿íèé òóñëàìæòàéãààð ò¿¿íèéã òîäîðõîéëæ íýð, õýìæýýñ, ýëåìåíòèéí òîî - ã çààæ ºãíº. Èíãýõýä ñàíàõ îé õóâààðèëàãääàã áà ò¿¿íèé ýëåìýíòýä äóãààðààð íü õàíäàæ áè÷èõ íºõöºë á¿ðääýã.
  • 14. Õ¿ñíýãòýí àðãóìåíòòàé äýä àëãîðèòì, ôóíêöèéí õóâüä õèéñâýð àðãóìåíòûã òîäîðõîéëæ ºãºõ人: 1. Ýíý àðãóìåíò íü õ¿ñíýãò ãýäãèéã ÿëãàæ, çààæ ºãºõ øààðäëàãàòàé . 2. Óã õ¿ñíýãòèéí ýëåìåíòèéí òîî, áóþó õýìæýýã ìºí àðãóìåíò áîëãîí àâäàã áàéõààð òîäîðõîéëîõ íü ç¿éòýé.
  • 15. Õèéñâýð àðãóìåíòûí æèãñààëò äîòîð õ¿ñíýãòèéã òîäîðõîéëîõäîî, ¿íäñýí àðãóìåíòýä ò¿¿íèéã òîäîðõîéëäîã àðãûã õýðýãëýäýã. Òýãýõäýý õ¿ñíýãòèéí æèíõýíý óòãûã õóóëæ äàìæóóëíà ãýäýã, ñàíàõ îé èõ øààðäàõààñ ãàäíà, õóãàöàà àëäàõàä õ¿ðäýã òóë õ¿ñíýãòèéí çºâõºí õàÿãèéã äàìæóóëàõ àðãà õýðýãëýíý. Èíãýñíýýð ýëåìýíòèéí m àõ òîîã áè÷èõ øààðäëàãàã¿é áîëíî.
  • 16. Æèøýý 3. : Íàòóðàëü òîî n,m áà à 1 ,à 2 ,...à n ; b 1 ,b 2 ,…b n ãýñýí 2 áîäèò òîîíû äàðààëàë ºãºãäñºí áîë 2 äàðààëëûí max óòãóóäûí ÿëãàâàðûí êâ-ûã îë. Ôóíêö array _max ( áîäèò õ¿ñíýãò à (5), íàò n) áîäèò max; int i; max:=a i I:=2,n ¿åä_äàâò õýðýâ max<a i áîë max:= à i Áóö (max);
  • 17. Æ: Àëã áîäèò õ¿ñíýãò à (mn), b(mn); íàò n,m,I; Áîäèò s; Îðóóë (n); Îðóóë (a i ; I:=1,n); Îðóóë ((m); Îðóóë (b i ; I:=1,m); s:=(array_max(a, n)-array_max(b,m)) 2 Ãàðãà (s) Òºãñ
  • 18. Æèøýý 4 : Áîäèò òîî à 1 ,à 2 , b 1 ,b 2 ,c 1 ,c 2 ºãºãäñºí áîë { ãýñýí øóãàìàí òýãøèòãýëèéí ñèñòåìèéí øèéäèéã îë. ¯¿íèéã êðàìåðèéí ä¿ðìýýð áîäíî.Ýíý ä¿ðýì ¸ñîîð ñèñòåìèéí ¿ë ìýäýãäýã÷¿¿äèéí ºìíºõ êîýôôèöèåíò áîëîí ñóë ãèø¿¿íýýð çîõèîñîí òîäîðõîéëîã÷óóäààð øèéäèéã øèíæèëæ òîãòîîäîã.¯¿íä :
  • 19. <ul><li>Õýðýâ d= 0 áîë ñèñòåì ãàíö øèéäòýé áºãººä x=d x /d , y=d y /d áàéíà. </li></ul><ul><li>Õýðýâ d,d x ,d y =0 áóþó d=0 áà d x 2 +d y 2 =0 áîë ñèñòåì òºãñãºëã¿é îëîí øèéäòýé. </li></ul><ul><li>Õýðýâ d=0 áà d x 2 +d y 2 =0 áîë ñèñòåì îãò øèéäã¿é áàéíà </li></ul><ul><li>Ýíäýýñ ¿çâýë 2-ð ýðýìáèéí òîäîðõîéëîã÷ áîäîõ àëãîðèòì 3-í óäàà øààðäàãäàõ òóë ºãñºí ìàòðèöàä õàðãàëçàõ òîäîðõîéëîã÷èéã áîäîõ ôóíêöèéã çîõèîæ àøèãëàâàë çîõèíî </li></ul><ul><li>Ôóíêö det( áîäèò õ¿ñíýãò a(2,2)) </li></ul><ul><li>Áîäèò ó ; </li></ul><ul><li>ó: =a 11 a 22 -a 12 b 21 </li></ul><ul><li>Áóö ( ó ) </li></ul>
  • 20. Ô óíêöèéã àøèãëàí øóãàìàí òýãøèòãýëèéí ñèñòåìèéã øèíæëýõ àëãîðèòìûã áè÷âýë: Æèøýý 5: íàò n=2; áîäèò õ¿ñíýãò a(n,n),c(n),d(n),b(n,n); áîäèò dd; íàò I,j,k; òåêñò s; i:=1,n ¿åä_äàâò {j:=1,n ¿åä_äàâò îðóóë (a ij ); îðóóë (c i )}; dd:=det(a); k:=1,n ¿åä_äàâò {I:=1,n ¿åä_äàâò {J:=1,n ¿åä_äàâò b ij :=a ij ; b ik :=c i ; };
  • 21. {J:=1,n ¿åä_äàâò b ij :=a ij ; b ik :=c i ; }; d k := det(b) }; Õýðýâ dd=0 áîë { ãàðãà (‘x=‘,d 1 /dd,’y=‘,d 2 /dd) ; s:=‘ ñèñòåì ãàíö øèéäòýé ’} Ýñâýë õýðýâ d 1 2 +d 2 2 =0 áîë s:=‘ ñèñòåì òºãñãºëã¿é îëîí øèéäòýé ’ Ýñâýë s:=‘ ñèñòåì øèéäã¿é ’ ãàðãà (s) Òºãñ
  • 22. Æèøýý 6 :Îþóòíû á¿ðòãýë ìýäýýëëèéã áîëîâñðóóëàõ àëãîðèòìä 2 öèôðèéí êîäîîñ õàðãàëçàõ 2 îðîíòîé òîîíû óòãûã îëîõ 10* (code( öèôð 1 ) - code(‘0’))+ code( öèôð 2 )-code(‘0’) õýëáýðòýé èëýðõèéëýë 4 óäàà àøèãëàãäñàí áàéãàà. Èéìýýñ 2 öèôðèéí êîä ºãºãäºõºä õàðãàëçàõ õî¸ð îðîíòîé òîîíû óòãûã áóöààæ ºãäºã ôóíêö val( òýìäýãò d,c)
  • 23. íàò s; s:= 10* (code(d) - code(‘0’))+ code(c)-code(‘0’) áóö (s); Ôóíêöèéã òîäîðõîéëæ õýðýãëýâýë óã àëãîðèòìûã äîîðõ õýëáýðòýé áè÷èæ áîëíî

×