Diff for ''

Revision 9
Author:
black
Time:
2022-10-16 02:30
Revision 1
Time:
2024-06-13 22:33
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
<includeonly><div class="thumb {{#switch: {{{align|}}} | left = tleft | center | centre = tnone | tright}} {{#if: {{{noclear|}}} | no-clear }}" style="width:{{#ifeq: {{{direction|horizontal}}} | vertical | {{#expr: {{#if: {{{width|}}} | {{{width}}} | {{{width1}}} }} + 12}} | {{#if: {{{width|}}} | {{#expr: 8 + ({{{width|0}}} + 4) * {{#if: {{{image5|}}} | 5 | {{#if: {{{image4|}}} | 4 | {{#if: {{{image3|}}} | 3 | 2 }} }} }} }} | {{#expr: 16 + {{{width1}}} + {{{width2}}} + {{{width3|0}}} + {{{width4|0}}} + {{{width5|0}}} + {{#if: {{{image5|}}} | 12 | {{#if: {{{image4|}}} | 8 | {{#if: {{{image3|}}} | 4 | 0 }} }} }} }} }} }}px;{{#switch: {{{align|}}} | center | centre = margin: 0 auto;}}">
<div class="thumbinner">
{{#if: {{{header|}}} | <div style="clear:both;font-weight:bold;text-align:{{{header_align|center}}};background:{{{header_background|transparent}}};">{{{header}}}</div> }}
<div style="{{#ifeq: {{{direction|horizontal}}} | horizontal | float:left;}}margin:1px;width:{{#expr: 2 + {{#if: {{{width|}}} | {{{width}}} | {{{width1}}} }} }}px;"><div class="thumbimage">[[Image:{{{image1}}}|{{#if: {{{width|}}} | {{{width}}} | {{{width1}}} }}px|{{{caption1|{{{box_caption}}}}}}]]</div>{{#if: {{{caption1|}}} | <div class="thumbcaption" style="clear:left;">{{{caption1}}}</div>}}</div>
<div style="{{#ifeq: {{{direction|horizontal}}} | horizontal | float:left;}}margin:1px;width:{{#expr: 2 + {{#if: {{{width|}}} | {{{width}}} | {{{width2}}} }} }}px;"><div class="thumbimage">[[Image:{{{image2}}}|{{#if: {{{width|}}} | {{{width}}} | {{{width2}}} }}px|{{{caption2|{{{box_caption}}}}}}]]</div>{{#if: {{{caption2|}}} | <div class="thumbcaption" style="clear:left;">{{{caption2}}}</div>}}</div>
{{#if: {{{image3|}}} | <div style="{{#ifeq: {{{direction|horizontal}}} | horizontal | float:left;}}margin:1px;width:{{#expr: 2 + {{#if: {{{width|}}} | {{{width}}} | {{{width3}}} }} }}px;"><div class="thumbimage">[[Image:{{{image3}}}|{{#if: {{{width|}}} | {{{width}}} | {{{width3}}} }}px|{{{caption3|{{{box_caption}}}}}}]]</div>{{#if: {{{caption3|}}} | <div class="thumbcaption" style="clear:left;">{{{caption3}}}</div>}}</div>
{{#if: {{{image4|}}} | <div style="{{#ifeq: {{{direction|horizontal}}} | horizontal | float:left;}}margin:1px;width:{{#expr: 2 + {{#if: {{{width|}}} | {{{width}}} | {{{width4}}} }} }}px;"><div class="thumbimage">[[Image:{{{image4}}}|{{#if: {{{width|}}} | {{{width}}} | {{{width4}}} }}px|{{{caption4|{{{box_caption}}}}}}]]</div>{{#if: {{{caption4|}}} | <div class="thumbcaption" style="clear:left;">{{{caption4}}}</div>}}</div>
{{#if: {{{image5|}}} | <div style="{{#ifeq: {{{direction|horizontal}}} | horizontal | float:left;}}margin:1px;width:{{#expr: 2 + {{#if: {{{width|}}} | {{{width}}} | {{{width5}}} }} }}px;"><div class="thumbimage">[[Image:{{{image5}}}|{{#if: {{{width|}}} | {{{width}}} | {{{width5}}} }}px|{{{caption5|{{{box_caption}}}}}}]]</div>{{#if: {{{caption5|}}} | <div class="thumbcaption" style="clear:left;">{{{caption5}}}</div>}}</div>}}}}}}
{{#if: {{{footer|}}} | <div class="thumbcaption" style="clear:left;text-align:{{{footer_align|left}}};background:{{{footer_background|transparent}}};">{{{footer}}}</div> }}</div></div></includeonly><noinclude>
{{documentation}}
<!-- PLEASE ADD CATEGORIES AND INTERWIKIS TO THE /doc SUBPAGE, THANKS -->
</noinclude>
# Prolog

<{ForumPost(poster="osk", timestamp=2011-05-11 17:36:37)}>
čau, nevěděl by někdo jak jednoduše udělat v prologu tohle zadání :
  
Na vstupu je zadán obecně nesouvislý graf. napište program v prologu, který na výstupu vytiskne výčtem všech uzlů jednotlivé komponenty tohoto grafu.
  
za jakoukoliv pomoc budu vděčný
<{/ForumPost}>

<{ForumPost(poster="PetrK", timestamp=2011-05-11 20:13:54)}>
Tohle by mohlo fungovat, ale casova narocnost neni uplne nejlepsi.
  
graf je reprezentovan seznamem sousedu:
sousedi(Vrchol, \[seznam sousedu]).

    komp(K):-sousedi(X, _), komponenty([X], [X], [], K).
    
    komponenty([], A, A2, Vyst):-sousedi(X, _), not(obsahuje(X, [A|A2])), komponenty([X], [X], [A|A2], Vyst).
    komponenty([], A, A2, [A|A2]).
    komponenty([H|T], A, V, Vyst):-sousedi(H, S), naZasobnik(S, T, A, T2, A2), komponenty(T2, A2, V, Vyst).
    
    naZasobnik([], T, A, T, A).
    naZasobnik([X|Xs], T, A, T2, A2):-not(member(X, A)), naZasobnik(Xs,[X|T], [X|A], T2, A2).
    naZasobnik([_|Xs], T, A, T2, A2):-naZasobnik(Xs, T, A, T2, A2).
    
    obsahuje(X, [H|_]):-member(X, H).
    obsahuje(X, [_|T]):-obsahuje(X, T).


<{/ForumPost}>

<{ForumPost(poster="QZuzka", timestamp=2011-05-12 14:52:05)}>
Nějak se nám tu rozmáhají lidi, kdo napíšou zadání a čekaj řešení - občas mi fórum taky hodně pomohlo, ale jak se to teď nahromadilo u prologu, tak to fakt nevypadá dobře. Už proto, že třeba někteří cvičící tu to čtou :)
  
spíš pro příští, lépe by působilo (alespoň na mě), kdybyste napsali aspoň trochu víc, třeba jak jste to zkusili nebo o jaké reprezentaci uvažujete...
  
---můj pohled, možná to ostatní vidí jinak---
<{/ForumPost}>

<{ForumPost(poster="Him", timestamp=2011-05-12 16:35:36)}>
[http://forum.matfyz.info/viewtopic.php?f=169&t=7677](http://forum.matfyz.info/viewtopic.php?f=169&t=7677)
[http://forum.matfyz.info/viewtopic.php?f=169&t=7672](http://forum.matfyz.info/viewtopic.php?f=169&t=7672)
  
Hlavne tyto dve vlakna vypadaji, ze jsou od jedne osoby :)
<{/ForumPost}>