<html>
<head>
<script>
document.write("Enter your list" + "<br>");
n=prompt("Enter n"," ");
a= new Array(n);
for(i=0;i<n;i++)
{
a[i]= parseInt(prompt("Enter a value"));
}
for(i=0;i<n;i++)
{
for(j=0;j<(n-i-1);j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
document.write("Sorted List is" +"<br>");
for(i=0;i<n;i++)
{
document.write(a[i] +" ");
}
</script>
</head>
<body></body>
<html>
<head>
<script>
document.write("Enter your list" + "<br>");
n=prompt("Enter n"," ");
a= new Array(n);
for(i=0;i<n;i++)
{
a[i]= parseInt(prompt("Enter a value"));
}
for(i=0;i<n;i++)
{
for(j=0;j<(n-i-1);j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
document.write("Sorted List is" +"<br>");
for(i=0;i<n;i++)
{
document.write(a[i] +" ");
}
</script>
</head>
<body></body>
<html>
No comments:
Post a Comment