Program Discussion :: Linked List
32 / 16
Write a program insert an element into ascending order list
Answer:
#include
#include
using namespace std;
void main()
{
int i, j, a, n, number[30];
coutn;
coutnumber[i];
for (i = 0; i < n; ++i)
{
for (j = i + 1; j < n; ++j)
{
if (number[i] > number[j])
{
a = number[i];
number[i] = number[j];
number[j] = a;
}
}
}
cout
Asked In ::
Language:
Aswin
7 Jul, 2017 9:30 AM
#include <stdio.h>
void main()
{
int i, j, a, n, number[30];
printf("Enter the value of N \n");
scanf("%d", &n);
printf("Enter the numbers \n");
for (i = 0; i < n; ++i)
scanf("%d", &number[i]);
for (i = 0; i < n; ++i)
{
for (j = i + 1; j < n; ++j)
{
if (number[i] > number[j])
{
a = number[i];
number[i] = number[j];
number[j] = a;
}
}
}
printf("The numbers arranged in ascending order are given below \n");
for (i = 0; i < n; ++i)
printf("%d\n", number[i]);
}
Language:
Neel
7 Jul, 2017 9:30 AM
#include <stdio.h>
#include<iostream>
using namespace std;
void main()
{
int i, j, a, n, number[30];
cout<<"Enter the value of N \n";
cin>>n;
cout<<"Enter the numbers \n";
for (i = 0; i < n; ++i)
cin>>number[i];
for (i = 0; i < n; ++i)
{
for (j = i + 1; j < n; ++j)
{
if (number[i] > number[j])
{
a = number[i];
number[i] = number[j];
number[j] = a;
}
}
}
cout<<"The numbers arranged in ascending order are given below \n";
for (i = 0; i < n; ++i)
cout<< number[i];
}
Language:
Prithivi
5 Dec, 2023 6:38 AM
def new_l(list1,n):
i=0
while i<len(list1) and list1[i]<n:
i =1
list1.insert(i,n)
return list1
list1=list(map(int,input().split()))
n=int(input())
print(new_l(list1,n))
Language:
Prithivi
5 Dec, 2023 6:38 AM
def new_l(list1,n):
i=0
while i<len(list1) and list1[i]<n:
i =1
list1.insert(i,n)
return list1
list1=list(map(int,input().split()))
n=int(input())
print(new_l(list1,n))
Language:
Prithivi
5 Dec, 2023 6:38 AM
def new_l(list1,n):
i=0
while i<len(list1) and list1[i]<n:
i =1
list1.insert(i,n)
return list1
list1=list(map(int,input().split()))
n=int(input())
print(new_l(list1,n))
Language:
Prithivi
5 Dec, 2023 6:38 AM
def new_l(list1,n):
i=0
while i<len(list1) and list1[i]<n:
i =1
list1.insert(i,n)
return list1
list1=list(map(int,input().split()))
n=int(input())
print(new_l(list1,n))
Language:
Prithivi
5 Dec, 2023 6:38 AM
def new_l(list1,n):
i=0
while i<len(list1) and list1[i]<n:
i =1
list1.insert(i,n)
return list1
list1=list(map(int,input().split()))
n=int(input())
print(new_l(list1,n))