SlideShare a Scribd company logo
Problema  COLOR ĂRI HĂRŢILOR Pop Eugen cls. A XI-a B
Enunţul problemei ,[object Object],[object Object]
Exemplu: 1 2 3 4 5 Ţara 1 – culoarea  Ţara 2 – culoarea  Ţara 3 – culoarea  Ţara 4 - culoarea  Ţara 5 – culoarea  ROŞU VERDE ROŞU ALBASTRU GALBEN ROŞU VERDE ROŞU ALBASTRU GALBEN
Implementare: Harta este furnizată programului cu ajutorul unei matrice An,n. Matricea  A  este simetrică. Pentru rezolvarea problemei se utilizează stiva  st , unde nivelul  k  al stivei simbolizează ţara  k , iar  st[k]  culoarea ataşată ţării k. Stiva are înălţimea  n  şi pe fiecare nivel ia valori între  1  şi  4 .
Program: program colorare _ harta; type stiva=array[1..100] of integer; var st: stiva; i,j,n,k:integer; as, ev:boolean; a:array[1..20, 1..20] of integer; procedure init(k:integer; var st:stiva); begin st[k]:=0; end; procedure succesor(var as: boolean; var st:stiva; k:integer); begin if st[k]<4 then begin st[k]:=st[k]+1; as:=true   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 (st[i]=st[k]) and (a[i,k]=1) 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 writeln('Tara= ', i, '; culoarea= ', st[i]); writeln('-------------'); end;
BEGIN write('Numarul de tari= '); 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; k:=1; init(k, st); while k>0 do begin   repeat   succesor(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; readln; END.

More Related Content

Recently uploaded

Papa Francisco canoniza los martires de Rumanía (Rumanian).pptx
Papa Francisco canoniza los martires de Rumanía (Rumanian).pptxPapa Francisco canoniza los martires de Rumanía (Rumanian).pptx
Papa Francisco canoniza los martires de Rumanía (Rumanian).pptx
Martin M Flynn
 
Raport proiect transfrontalier Culori fermecate.pdf
Raport proiect transfrontalier Culori fermecate.pdfRaport proiect transfrontalier Culori fermecate.pdf
Raport proiect transfrontalier Culori fermecate.pdf
savinioana
 
Proces verbal sedinta cu parintii (26.09.2023).docx
Proces verbal sedinta cu parintii (26.09.2023).docxProces verbal sedinta cu parintii (26.09.2023).docx
Proces verbal sedinta cu parintii (26.09.2023).docx
AureliaTertereanu
 
Să ne împrietenim cu lectura Ermurachi Nina/ Pruncia Monica
Să ne împrietenim cu lectura Ermurachi Nina/ Pruncia MonicaSă ne împrietenim cu lectura Ermurachi Nina/ Pruncia Monica
Să ne împrietenim cu lectura Ermurachi Nina/ Pruncia Monica
NinaTofanErmurachi
 
Analiza SWOT - fisa de lucru aplicabila pentru liceu
Analiza SWOT - fisa de lucru aplicabila pentru liceuAnaliza SWOT - fisa de lucru aplicabila pentru liceu
Analiza SWOT - fisa de lucru aplicabila pentru liceu
Andreea Balaci
 
Patrimoniul cultural PROIECT clasa a 6 a IECHEI SORAYA GABRIELA
Patrimoniul cultural PROIECT clasa a 6 a IECHEI SORAYA GABRIELAPatrimoniul cultural PROIECT clasa a 6 a IECHEI SORAYA GABRIELA
Patrimoniul cultural PROIECT clasa a 6 a IECHEI SORAYA GABRIELA
iecheisorayagabriela
 
Studiu Nike, Dascalu Ana-Georgiana, Crp.
Studiu Nike, Dascalu Ana-Georgiana, Crp.Studiu Nike, Dascalu Ana-Georgiana, Crp.
Studiu Nike, Dascalu Ana-Georgiana, Crp.
GeorgianaDascalu1
 
Antarctica caracterizare fizico geografica
Antarctica caracterizare fizico geograficaAntarctica caracterizare fizico geografica
Antarctica caracterizare fizico geografica
Alina70851
 

Recently uploaded (8)

Papa Francisco canoniza los martires de Rumanía (Rumanian).pptx
Papa Francisco canoniza los martires de Rumanía (Rumanian).pptxPapa Francisco canoniza los martires de Rumanía (Rumanian).pptx
Papa Francisco canoniza los martires de Rumanía (Rumanian).pptx
 
Raport proiect transfrontalier Culori fermecate.pdf
Raport proiect transfrontalier Culori fermecate.pdfRaport proiect transfrontalier Culori fermecate.pdf
Raport proiect transfrontalier Culori fermecate.pdf
 
Proces verbal sedinta cu parintii (26.09.2023).docx
Proces verbal sedinta cu parintii (26.09.2023).docxProces verbal sedinta cu parintii (26.09.2023).docx
Proces verbal sedinta cu parintii (26.09.2023).docx
 
Să ne împrietenim cu lectura Ermurachi Nina/ Pruncia Monica
Să ne împrietenim cu lectura Ermurachi Nina/ Pruncia MonicaSă ne împrietenim cu lectura Ermurachi Nina/ Pruncia Monica
Să ne împrietenim cu lectura Ermurachi Nina/ Pruncia Monica
 
Analiza SWOT - fisa de lucru aplicabila pentru liceu
Analiza SWOT - fisa de lucru aplicabila pentru liceuAnaliza SWOT - fisa de lucru aplicabila pentru liceu
Analiza SWOT - fisa de lucru aplicabila pentru liceu
 
Patrimoniul cultural PROIECT clasa a 6 a IECHEI SORAYA GABRIELA
Patrimoniul cultural PROIECT clasa a 6 a IECHEI SORAYA GABRIELAPatrimoniul cultural PROIECT clasa a 6 a IECHEI SORAYA GABRIELA
Patrimoniul cultural PROIECT clasa a 6 a IECHEI SORAYA GABRIELA
 
Studiu Nike, Dascalu Ana-Georgiana, Crp.
Studiu Nike, Dascalu Ana-Georgiana, Crp.Studiu Nike, Dascalu Ana-Georgiana, Crp.
Studiu Nike, Dascalu Ana-Georgiana, Crp.
 
Antarctica caracterizare fizico geografica
Antarctica caracterizare fizico geograficaAntarctica caracterizare fizico geografica
Antarctica caracterizare fizico geografica
 

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 Hubspot
Marius 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 ChatGPT
Expeed 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 Engineerings
Pixeldarts
 
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
ThinkNow
 
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
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
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
Neil 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 2024
Albert 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 Insights
Kurio // 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 2024
Search 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 summary
SpeakerHub
 
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 Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit 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 management
MindGenius
 
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...
 

Problema Colorarii Hartilor

  • 1. Problema COLOR ĂRI HĂRŢILOR Pop Eugen cls. A XI-a B
  • 2.
  • 3. Exemplu: 1 2 3 4 5 Ţara 1 – culoarea Ţara 2 – culoarea Ţara 3 – culoarea Ţara 4 - culoarea Ţara 5 – culoarea ROŞU VERDE ROŞU ALBASTRU GALBEN ROŞU VERDE ROŞU ALBASTRU GALBEN
  • 4. Implementare: Harta este furnizată programului cu ajutorul unei matrice An,n. Matricea A este simetrică. Pentru rezolvarea problemei se utilizează stiva st , unde nivelul k al stivei simbolizează ţara k , iar st[k] culoarea ataşată ţării k. Stiva are înălţimea n şi pe fiecare nivel ia valori între 1 şi 4 .
  • 5. Program: program colorare _ harta; type stiva=array[1..100] of integer; var st: stiva; i,j,n,k:integer; as, ev:boolean; a:array[1..20, 1..20] of integer; procedure init(k:integer; var st:stiva); begin st[k]:=0; end; procedure succesor(var as: boolean; var st:stiva; k:integer); begin if st[k]<4 then begin st[k]:=st[k]+1; as:=true end else as:=false end;
  • 6. procedure valid(var ev:boolean; st:stiva; k:integer); var i:integer; begin ev:=true; for i:=1 to k-1 do if (st[i]=st[k]) and (a[i,k]=1) 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 writeln('Tara= ', i, '; culoarea= ', st[i]); writeln('-------------'); end;
  • 7. BEGIN write('Numarul de tari= '); 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; k:=1; init(k, st); while k>0 do begin repeat succesor(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; readln; END.