SlideShare a Scribd company logo
1 of 6
Prezentare  La  Informatica   Problema  Comis Voiajorului Kukta Robert cl. a XI-a B
Enuntul  Problemei Un comis voiajor trebuie sa viziteze un numar  n   de orase.  Initial se afla intr-una din ele. Acel oras este notat cu 1. Comis voiajorul doreste sa nu treaca de doua ori prin acelasi oras, iar la intoarcere sa revina in orasul 1.  Cunoscand legaturile se cere sa se tipareasca toate drumurile posibile pe care le poate efectua comisul voiajor
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Exemplu Pentru  n=6  Ai,j va fi:  - 1 daca intre  i  si  j  se afla drum  - 0 daca intre  i  si  j  nu se afla drum  Si se va afisa in program: 1.2  Drumurile posibile sunt  2.3  1234561 2.5  1254361 2.6  1654321 2.1  1634521 3.4 3.5 3.6 3.2 4.5 4.3 5.6 5.2 5.3 5.4
program comis_voiajor; type stiva=array[1..100] of integer; type mat= array[1..100,1..100] of integer; var st:stiva; a:mat; as,ev:Boolean; n,k,i:integer; Procedure init (k:integer;var st:stiva); Begin St[k]:=1; End; Procedure successor (var as:Boolean; var st:stiva;k:integer); Begin  If st[k]<n then begin As:=true; St[k]:=st[k]+1; End   Else as:=false; End; Procedure valid(var ev:Boolean; st:stiva; k:integer); Var i:integer; Begin Ev := true; For i:=1 to k-1 do  If  a[st[k-1],st[k]]=0 then ev:=false  Else For i:=1 to k-1 do  If st[i]=st[k] then ev := false Else  If (k=n) and (a[1,st[k]]=0) then ev := false; End; function solutie (k:integer):Boolean; begin solutie:=(k=n); end; procedure tipar;  var i:integer; begin for i:=1 to n do write( st[i]); end;
BEGIN write(‘n=’);readln(n); for i:=1 to n do  for j:=1 to i-1 do begin  write (‘a[‘,I,’,’,j,’]=’);readln(a[I,j]); a[j,i]:=a[I,j]; end; st[1]:=1; k:=2; init(k,st); while k>1 do begin repeat successor (as,st,k); if as then valid(ev,st,k); Until (not as) OR (as AND ev); If as then  If solutie(k) then tipar Else begin K:=k+1; Init(k,st); End Else k:=k+1; End; END.

More Related Content

Recently uploaded

Acatistul Sfântului apostol şi evanghelist Ioan, bogoslovul (al doilea acatis...
Acatistul Sfântului apostol şi evanghelist Ioan, bogoslovul (al doilea acatis...Acatistul Sfântului apostol şi evanghelist Ioan, bogoslovul (al doilea acatis...
Acatistul Sfântului apostol şi evanghelist Ioan, bogoslovul (al doilea acatis...Stea emy
 
Canon de rugăciune către Sfântul mucenic Acachie (s.v. 7 mai / s.n. 20 mai)
Canon de rugăciune către Sfântul mucenic Acachie (s.v. 7 mai / s.n. 20 mai)Canon de rugăciune către Sfântul mucenic Acachie (s.v. 7 mai / s.n. 20 mai)
Canon de rugăciune către Sfântul mucenic Acachie (s.v. 7 mai / s.n. 20 mai)Stea emy
 
Acatistul Sfinților cuvioși Sila, Paisie și Natan de la Sihăstria Putnei (16 ...
Acatistul Sfinților cuvioși Sila, Paisie și Natan de la Sihăstria Putnei (16 ...Acatistul Sfinților cuvioși Sila, Paisie și Natan de la Sihăstria Putnei (16 ...
Acatistul Sfinților cuvioși Sila, Paisie și Natan de la Sihăstria Putnei (16 ...Stea emy
 
Canoane de rugăciune către Sfinții cuvioși Sila, Paisie și Natan de la Sihăst...
Canoane de rugăciune către Sfinții cuvioși Sila, Paisie și Natan de la Sihăst...Canoane de rugăciune către Sfinții cuvioși Sila, Paisie și Natan de la Sihăst...
Canoane de rugăciune către Sfinții cuvioși Sila, Paisie și Natan de la Sihăst...Stea emy
 
Sfântul apostol Simon Zilotul şi Biserica Podeanu
Sfântul apostol Simon Zilotul şi Biserica PodeanuSfântul apostol Simon Zilotul şi Biserica Podeanu
Sfântul apostol Simon Zilotul şi Biserica PodeanuStea emy
 
Acatistul Sfântului slăvitului apostol şi evanghelist Ioan (al treilea acatis...
Acatistul Sfântului slăvitului apostol şi evanghelist Ioan (al treilea acatis...Acatistul Sfântului slăvitului apostol şi evanghelist Ioan (al treilea acatis...
Acatistul Sfântului slăvitului apostol şi evanghelist Ioan (al treilea acatis...Stea emy
 
Canon de rugăciune către Sfântul apostol Simon, zilotul (10 mai)
Canon de rugăciune către Sfântul apostol Simon, zilotul (10 mai)Canon de rugăciune către Sfântul apostol Simon, zilotul (10 mai)
Canon de rugăciune către Sfântul apostol Simon, zilotul (10 mai)Stea emy
 
Acatistul Sfintei mari muceniţe Irina din Maghedon (s.v. 5 mai / s.n. 18 mai)
Acatistul Sfintei mari muceniţe Irina din Maghedon (s.v. 5 mai / s.n. 18 mai)Acatistul Sfintei mari muceniţe Irina din Maghedon (s.v. 5 mai / s.n. 18 mai)
Acatistul Sfintei mari muceniţe Irina din Maghedon (s.v. 5 mai / s.n. 18 mai)Stea emy
 
Canon de rugăciune către Sfânta Cruce, în cinstea arătării ei la Ierusalim, î...
Canon de rugăciune către Sfânta Cruce, în cinstea arătării ei la Ierusalim, î...Canon de rugăciune către Sfânta Cruce, în cinstea arătării ei la Ierusalim, î...
Canon de rugăciune către Sfânta Cruce, în cinstea arătării ei la Ierusalim, î...Stea emy
 
Acatistul Sfântului apostol şi evanghelist Ioan
Acatistul Sfântului apostol şi evanghelist IoanAcatistul Sfântului apostol şi evanghelist Ioan
Acatistul Sfântului apostol şi evanghelist IoanStea emy
 

Recently uploaded (10)

Acatistul Sfântului apostol şi evanghelist Ioan, bogoslovul (al doilea acatis...
Acatistul Sfântului apostol şi evanghelist Ioan, bogoslovul (al doilea acatis...Acatistul Sfântului apostol şi evanghelist Ioan, bogoslovul (al doilea acatis...
Acatistul Sfântului apostol şi evanghelist Ioan, bogoslovul (al doilea acatis...
 
Canon de rugăciune către Sfântul mucenic Acachie (s.v. 7 mai / s.n. 20 mai)
Canon de rugăciune către Sfântul mucenic Acachie (s.v. 7 mai / s.n. 20 mai)Canon de rugăciune către Sfântul mucenic Acachie (s.v. 7 mai / s.n. 20 mai)
Canon de rugăciune către Sfântul mucenic Acachie (s.v. 7 mai / s.n. 20 mai)
 
Acatistul Sfinților cuvioși Sila, Paisie și Natan de la Sihăstria Putnei (16 ...
Acatistul Sfinților cuvioși Sila, Paisie și Natan de la Sihăstria Putnei (16 ...Acatistul Sfinților cuvioși Sila, Paisie și Natan de la Sihăstria Putnei (16 ...
Acatistul Sfinților cuvioși Sila, Paisie și Natan de la Sihăstria Putnei (16 ...
 
Canoane de rugăciune către Sfinții cuvioși Sila, Paisie și Natan de la Sihăst...
Canoane de rugăciune către Sfinții cuvioși Sila, Paisie și Natan de la Sihăst...Canoane de rugăciune către Sfinții cuvioși Sila, Paisie și Natan de la Sihăst...
Canoane de rugăciune către Sfinții cuvioși Sila, Paisie și Natan de la Sihăst...
 
Sfântul apostol Simon Zilotul şi Biserica Podeanu
Sfântul apostol Simon Zilotul şi Biserica PodeanuSfântul apostol Simon Zilotul şi Biserica Podeanu
Sfântul apostol Simon Zilotul şi Biserica Podeanu
 
Acatistul Sfântului slăvitului apostol şi evanghelist Ioan (al treilea acatis...
Acatistul Sfântului slăvitului apostol şi evanghelist Ioan (al treilea acatis...Acatistul Sfântului slăvitului apostol şi evanghelist Ioan (al treilea acatis...
Acatistul Sfântului slăvitului apostol şi evanghelist Ioan (al treilea acatis...
 
Canon de rugăciune către Sfântul apostol Simon, zilotul (10 mai)
Canon de rugăciune către Sfântul apostol Simon, zilotul (10 mai)Canon de rugăciune către Sfântul apostol Simon, zilotul (10 mai)
Canon de rugăciune către Sfântul apostol Simon, zilotul (10 mai)
 
Acatistul Sfintei mari muceniţe Irina din Maghedon (s.v. 5 mai / s.n. 18 mai)
Acatistul Sfintei mari muceniţe Irina din Maghedon (s.v. 5 mai / s.n. 18 mai)Acatistul Sfintei mari muceniţe Irina din Maghedon (s.v. 5 mai / s.n. 18 mai)
Acatistul Sfintei mari muceniţe Irina din Maghedon (s.v. 5 mai / s.n. 18 mai)
 
Canon de rugăciune către Sfânta Cruce, în cinstea arătării ei la Ierusalim, î...
Canon de rugăciune către Sfânta Cruce, în cinstea arătării ei la Ierusalim, î...Canon de rugăciune către Sfânta Cruce, în cinstea arătării ei la Ierusalim, î...
Canon de rugăciune către Sfânta Cruce, în cinstea arătării ei la Ierusalim, î...
 
Acatistul Sfântului apostol şi evanghelist Ioan
Acatistul Sfântului apostol şi evanghelist IoanAcatistul Sfântului apostol şi evanghelist Ioan
Acatistul Sfântului apostol şi evanghelist Ioan
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Prezentare Info Robi

  • 1. Prezentare La Informatica Problema Comis Voiajorului Kukta Robert cl. a XI-a B
  • 2. Enuntul Problemei Un comis voiajor trebuie sa viziteze un numar n de orase. Initial se afla intr-una din ele. Acel oras este notat cu 1. Comis voiajorul doreste sa nu treaca de doua ori prin acelasi oras, iar la intoarcere sa revina in orasul 1. Cunoscand legaturile se cere sa se tipareasca toate drumurile posibile pe care le poate efectua comisul voiajor
  • 3.
  • 4. Exemplu Pentru n=6 Ai,j va fi: - 1 daca intre i si j se afla drum - 0 daca intre i si j nu se afla drum Si se va afisa in program: 1.2 Drumurile posibile sunt 2.3 1234561 2.5 1254361 2.6 1654321 2.1 1634521 3.4 3.5 3.6 3.2 4.5 4.3 5.6 5.2 5.3 5.4
  • 5. program comis_voiajor; type stiva=array[1..100] of integer; type mat= array[1..100,1..100] of integer; var st:stiva; a:mat; as,ev:Boolean; n,k,i:integer; Procedure init (k:integer;var st:stiva); Begin St[k]:=1; End; Procedure successor (var as:Boolean; var st:stiva;k:integer); Begin If st[k]<n then begin As:=true; St[k]:=st[k]+1; End Else as:=false; End; Procedure valid(var ev:Boolean; st:stiva; k:integer); Var i:integer; Begin Ev := true; For i:=1 to k-1 do If a[st[k-1],st[k]]=0 then ev:=false Else For i:=1 to k-1 do If st[i]=st[k] then ev := false Else If (k=n) and (a[1,st[k]]=0) then ev := false; End; function solutie (k:integer):Boolean; begin solutie:=(k=n); end; procedure tipar; var i:integer; begin for i:=1 to n do write( st[i]); end;
  • 6. BEGIN write(‘n=’);readln(n); for i:=1 to n do for j:=1 to i-1 do begin write (‘a[‘,I,’,’,j,’]=’);readln(a[I,j]); a[j,i]:=a[I,j]; end; st[1]:=1; k:=2; init(k,st); while k>1 do begin repeat successor (as,st,k); if as then valid(ev,st,k); Until (not as) OR (as AND ev); If as then If solutie(k) then tipar Else begin K:=k+1; Init(k,st); End Else k:=k+1; End; END.