<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=2563_%E2%80%93_FAdCresc</id>
	<title>2563 – FAdCresc - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=2563_%E2%80%93_FAdCresc"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=2563_%E2%80%93_FAdCresc&amp;action=history"/>
	<updated>2026-05-01T04:54:46Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=2563_%E2%80%93_FAdCresc&amp;diff=9767&amp;oldid=prev</id>
		<title>Hotico Iulia Denisa: /* Cerința */</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=2563_%E2%80%93_FAdCresc&amp;diff=9767&amp;oldid=prev"/>
		<updated>2024-05-09T08:27:23Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Cerința&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 08:27, 9 May 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l12&quot;&gt;Line 12:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 12:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Cerința==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Cerința==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Să se scrie o funcție &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;C++ &lt;/del&gt;cu următorul prototip:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Să se scrie o funcție &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Python &lt;/ins&gt;cu următorul prototip:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      &lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     void ins_cresc(nod *&amp;amp;p, int x);&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     void ins_cresc(nod *&amp;amp;p, int x);&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Hotico Iulia Denisa</name></author>
	</entry>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=2563_%E2%80%93_FAdCresc&amp;diff=9735&amp;oldid=prev</id>
		<title>Cristina94: Pagină nouă: ==Enunţ== Se consideră o listă liniară simplu înlănțuită, alocată dinamic, în care elementele sunt de tipul declarat mai jos:      struct nod{       int info;       nod * urm;     };  în care câmpul info memorează un număr întreg, iar câmpul urm memorează adresa următorului element al listei.  Informațiile din listă sunt ordonate crescător.  ==Cerința== Să se scrie o funcție C++ cu următorul prototip:          void ins_cresc(nod *&amp;p, int x);  care ins...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=2563_%E2%80%93_FAdCresc&amp;diff=9735&amp;oldid=prev"/>
		<updated>2024-03-29T04:47:45Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: ==Enunţ== Se consideră o listă liniară simplu înlănțuită, alocată dinamic, în care elementele sunt de tipul declarat mai jos:      struct nod{       int info;       nod * urm;     };  în care câmpul info memorează un număr întreg, iar câmpul urm memorează adresa următorului element al listei.  Informațiile din listă sunt ordonate crescător.  ==Cerința== Să se scrie o funcție C++ cu următorul prototip:          void ins_cresc(nod *&amp;amp;p, int x);  care ins...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Enunţ==&lt;br /&gt;
Se consideră o listă liniară simplu înlănțuită, alocată dinamic, în care elementele sunt de tipul declarat mai jos:&lt;br /&gt;
&lt;br /&gt;
    struct nod{&lt;br /&gt;
      int info;&lt;br /&gt;
      nod * urm;&lt;br /&gt;
    };&lt;br /&gt;
&lt;br /&gt;
în care câmpul info memorează un număr întreg, iar câmpul urm memorează adresa următorului element al listei.&lt;br /&gt;
&lt;br /&gt;
Informațiile din listă sunt ordonate crescător.&lt;br /&gt;
&lt;br /&gt;
==Cerința==&lt;br /&gt;
Să se scrie o funcție C++ cu următorul prototip:&lt;br /&gt;
    &lt;br /&gt;
    void ins_cresc(nod *&amp;amp;p, int x);&lt;br /&gt;
&lt;br /&gt;
care inserează în listă un nou nod care memorează valoarea x astfel încât informațiile din lista să fie în continuare ordonate crescător; pointerul p are ca valoarea adresa primului element din listă.&lt;br /&gt;
&lt;br /&gt;
==Restricții și precizări==&lt;br /&gt;
*numele funcției va fi ins_cresc.&lt;br /&gt;
*lista conține inițial cel puțin un nod.&lt;br /&gt;
*rezolvarea problemei se va face în ptyhon&lt;br /&gt;
&lt;br /&gt;
==Important==&lt;br /&gt;
Soluţia propusă va conţine definiţia funcţiei cerute. Prezenţa în soluţie a altor instrucţiuni poate duce erori de compilare sau de execuţie care vor avea ca efect depunctarea soluţiei.&lt;br /&gt;
&lt;br /&gt;
==Rezolvare==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line&amp;gt;&lt;br /&gt;
#2563 FAdCresc&lt;br /&gt;
class Node:&lt;br /&gt;
  def __init__(self, info):&lt;br /&gt;
    self.info = info&lt;br /&gt;
    self.next = None&lt;br /&gt;
&lt;br /&gt;
def ins_cresc(p, x):&lt;br /&gt;
  new_node = Node(x)&lt;br /&gt;
  &lt;br /&gt;
  # Dacă lista este goală sau noul nod trebuie inserat înaintea primului nod&lt;br /&gt;
  if p is None or x &amp;lt; p.info:&lt;br /&gt;
    new_node.next = p&lt;br /&gt;
    p = new_node&lt;br /&gt;
    return p&lt;br /&gt;
  &lt;br /&gt;
  # Parcurgem lista până găsim locul corect pentru inserare&lt;br /&gt;
  current = p&lt;br /&gt;
  while current.next is not None and current.next.info &amp;lt; x:&lt;br /&gt;
    current = current.next&lt;br /&gt;
  &lt;br /&gt;
  # Inserăm noul nod între current și current.next&lt;br /&gt;
  new_node.next = current.next&lt;br /&gt;
  current.next = new_node&lt;br /&gt;
  &lt;br /&gt;
  return p&lt;br /&gt;
&lt;br /&gt;
# Funcție pentru afișarea listei&lt;br /&gt;
def print_list(p):&lt;br /&gt;
  current = p&lt;br /&gt;
  while current is not None:&lt;br /&gt;
    print(current.info, end=&amp;quot; &amp;quot;)&lt;br /&gt;
    current = current.next&lt;br /&gt;
  print()&lt;br /&gt;
&lt;br /&gt;
# Funcție pentru crearea listei inițiale&lt;br /&gt;
def create_list(values):&lt;br /&gt;
  if not values:&lt;br /&gt;
    return None&lt;br /&gt;
  &lt;br /&gt;
  p = Node(values[0])&lt;br /&gt;
  current = p&lt;br /&gt;
  for val in values[1:]:&lt;br /&gt;
    current.next = Node(val)&lt;br /&gt;
    current = current.next&lt;br /&gt;
  &lt;br /&gt;
  return p&lt;br /&gt;
    &lt;br /&gt;
# Funcție pentru afișarea listei în ordine crescătoare&lt;br /&gt;
def print_list_sorted(p):&lt;br /&gt;
  # Creează o listă pentru a stoca valorile din listă&lt;br /&gt;
  values = []&lt;br /&gt;
  current = p&lt;br /&gt;
  while current is not None:&lt;br /&gt;
    values.append(current.info)&lt;br /&gt;
    current = current.next&lt;br /&gt;
  &lt;br /&gt;
  # Sortează valorile&lt;br /&gt;
  values.sort()&lt;br /&gt;
  &lt;br /&gt;
  # Afișează valorile sortate&lt;br /&gt;
  for val in values:&lt;br /&gt;
    print(val, end=&amp;quot; &amp;quot;)&lt;br /&gt;
  print()&lt;br /&gt;
&lt;br /&gt;
if __name__ == &amp;quot;__main__&amp;quot;:&lt;br /&gt;
  # Cream lista de test&lt;br /&gt;
  values = [2, 4, 8, 6, 1, 0]&lt;br /&gt;
  p = create_list(values)&lt;br /&gt;
&lt;br /&gt;
  #  Afisam lista in ordine crescatoare&lt;br /&gt;
  print(&amp;quot;Lista creata:&amp;quot;)&lt;br /&gt;
  print_list_sorted(p)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cristina94</name></author>
	</entry>
</feed>