Write a program using a one-dimensional array to implement a bubble sort algorithm.
The program will ask the user how many items to be processed and then the program will
display the original arrangement of the numbers and then display the sorted
arrangement of the numbers on the screen.
I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360. My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking and Arduino Project development at a very affordable price.
My personal website is http://www.jakerpomperada.com
My programming website is http://www.jakerpomperada.blogspot.com
I am also a book author you can purchase my books on computer programming and information technology in the following links below.
https://www.mindshaperspublishing.com/
https://www.unlimitedbooksph.com/
The program will ask the user how many items to be processed and then the program will
display the original arrangement of the numbers and then display the sorted
arrangement of the numbers on the screen.
I am currently accepting programming work inventory system, enrollment system, accounting system, payroll system, information system, website design and development using WordPress, IT projects, school and application development, programming projects, thesis, and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360. My telephone number at home here in Bacolod City, Negros Occidental Philippines is +63 (034) 4335675.
Here in Bacolod City, Negros Occidental I also accepting computer repair, web development using WordPress, Computer Networking and Arduino Project development at a very affordable price.
My personal website is http://www.jakerpomperada.com
My programming website is http://www.jakerpomperada.blogspot.com
I am also a book author you can purchase my books on computer programming and information technology in the following links below.
https://www.mindshaperspublishing.com/
https://www.unlimitedbooksph.com/
Sample Program Output
Program Listing
# bubble_sort_array.pl
# Author : Jake R. Pomperada,MAED-IT,MIT
# Date : April 11, 2020 Saturday 4:19 PM
# Location : Bacolod City, Negros Occidental
# Email : jakerpomperada@gmail.com
# Websites : http://www.jakerpomperada.com
# http://www.jakerpomperada.blogspot.com
@$items=(1..50);
$num_input,$a=0;
$b=0,$temp=0;
printf("\n\n");
printf("\tBubble Sort Using Arrays in Perl");
printf("\n\n");
printf("\tGive the size of array: ");
chomp($num_input=<STDIN>);
printf("\n");
for($a=0;$a<$num_input;$a+=1)
{
printf("\tEnter Grade No. %d : ",$a+1);
chomp($items[$a]=<STDIN>);
}
printf("\n\n");
printf("\tOriginal Array Elements Arrangement");
printf("\n");
printf("\t");
for($a=0;$a<$num_input;$a+=1) {
printf("%d ",$items[$a]);
}
# Bubble Sort Code
for($a=1;$a<$num_input;$a+=1)
{
for($b=0;$b<($num_input-$a);$b+=1) {
if($items[$b]>$items[$b+1])
{
$temp=$items[$b];
$items[$b]=$items[$b+1];
$items[$b+1]=$temp;
}
}
}
printf("\n\n");
printf("\tSorted Array Elements Arrangement");
printf("\n");
printf("\t");
for($a=0;$a<$num_input;$a+=1) {
printf("%d ",$items[$a]);
}
printf("\n\n");
printf("\tEnd of Program");
printf("\n\n");
No comments:
Post a Comment