logo

Crowdly

Browser

Додати до Chrome

Se considera crearea cu reordonare a unei liste dinamice function nod(x){ th...

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

Se considera crearea cu reordonare a unei liste dinamice

function nod(x){

this.contor=1;

this.x=x;

this.urmator=null;

}

function inserare(){

x=eval(prompt("val x",""));

fanion.x=x;

q1=inceput;

if(q1==fanion){

inceput=new nod(x);

inceput.urmator=fanion;

}

else

if(q1.x==x)

q1.contor++;

else

do{

q2=q1;

q1=q2.urmator;

}while (q1.x!=x);

if(q1==fanion){

q=new nod(x);

q.urmator=inceput;

inceput=q;

}

else{

q1.contor++;

q2.urmator=q1.urmator;

q1.urmator=inceput;

inceput=q1;

}

}

function afisare(){

s=""; q=inceput;

while(q!=fanion){

s+="q.x="+q.x+"q.contor="+q.contor+"<br>";

q=q.urmator;

}

document.write("Lista: <br>"+s);

}

inceput=new nod(0); fanion= inceput

c=eval(prompt("1-inserare, 2-afisare",""));

while(c==1 || c==2){

if(c==1)

inserare();

else

afisare();

c=eval(prompt("1-inserare, 2-afisare",""));

}

Faceti asocierile (inserarea unui nod nou):

Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на elearning.e-uvt.ro?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!

Browser

Додати до Chrome