6 Replies - 806 Views - Last Post: 29 January 2009 - 01:54 PM Rate Topic: -----

#1 maiko_pOh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 29-January 09

help me how to insert my selection 2 my bubble sort

Posted 29 January 2009 - 09:54 AM

import java.io.*;
class naks
{
public static void main(String args[]) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int num;
System.out.print("Enter the number of elements to be entered:"+"\t");
num=Integer.parseInt(br.readLine());
int arr[]=new int[num];

for(int i=0;i< num;i++)
{
System.out.print("index["+i+"]:"+"\t");
arr[i]=Integer.parseInt(br.readLine());
}
System.out.print("Entered numbers:"+" ");
{
	for(int i=0;i<num;i++)
			System.out.print(arr[i]);
}
{System.out.println("\n"+"bubbleSort"+"	");

}
for(int i=0;i< num;i++)
{
for(int j=i+1;j< num;j++)
{
if(arr[i]>arr[j])
{
int temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
for(int k=0;k<num;k++){
System.out.print(arr[k]+"\t");
System.out.print("\t");
}
}
}
}   
}
}





this my question can u help me how to insert my selection sort in this program/....

Is This A Good Question/Topic? 0
  • +

Replies To: help me how to insert my selection 2 my bubble sort

#2 maiko_pOh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 29-January 09

Re: help me how to insert my selection 2 my bubble sort

Posted 29 January 2009 - 09:55 AM

import java.io.*;
class naks
{
public static void main(String args[]) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int num;
System.out.print("Enter the number of elements to be entered:"+"\t");
num=Integer.parseInt(br.readLine());
int arr[]=new int[num];

for(int i=0;i< num;i++)
{
System.out.print("index["+i+"]:"+"\t");
arr[i]=Integer.parseInt(br.readLine());
}
System.out.print("Entered numbers:"+" ");
{
	for(int i=0;i<num;i++)
			System.out.print(arr[i]);
}
{System.out.println("\n"+"bubbleSort"+"	");

}
for(int i=0;i< num;i++)
{
for(int j=i+1;j< num;j++)
{
if(arr[i]>arr[j])
{
int temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
for(int k=0;k<num;k++){
System.out.print(arr[k]+"\t");
System.out.print("\t");
}
}
}
}   
}
}





this my question can u help me how to insert my selection sort in this program/....

W_W EDIT: code tags.
Was This Post Helpful? 0
  • +
  • -

#3 William_Wilson  Icon User is offline

  • lost in compilation
  • member icon

Reputation: 205
  • View blog
  • Posts: 4,807
  • Joined: 23-December 05

Re: help me how to insert my selection 2 my bubble sort

Posted 29 January 2009 - 10:17 AM

We are not going to do the work for you. Also please use indenting, even small bits of code become impossible to understand without it.

:code:
Was This Post Helpful? 0
  • +
  • -

#4 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1148
  • View blog
  • Posts: 7,144
  • Joined: 07-September 06

Re: help me how to insert my selection 2 my bubble sort

Posted 29 January 2009 - 01:36 PM

Moved to Java.

Also please post your code like so:
:code:
Was This Post Helpful? 0
  • +
  • -

#5 Gloin  Icon User is offline

  • Expert Schmexpert...
  • member icon

Reputation: 235
  • View blog
  • Posts: 4,489
  • Joined: 04-August 08

Re: help me how to insert my selection 2 my bubble sort

Posted 29 January 2009 - 01:43 PM

Do you want to insert an implementation of selection-sort into this program? Just so we have the question clear..
Was This Post Helpful? 0
  • +
  • -

#6 BigAnt  Icon User is offline

  • May Your Swords Stay Sharp
  • member icon

Reputation: 101
  • View blog
  • Posts: 2,392
  • Joined: 16-August 08

Re: help me how to insert my selection 2 my bubble sort

Posted 29 January 2009 - 01:45 PM

So what do you want it to do the Bubble sort and the Selection Sort?

It is better to create methods for each of these, rather than place everything in main.

There are code snippets available on this site for sorting of all kind, including bubble and selection.
Was This Post Helpful? 0
  • +
  • -

#7 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1148
  • View blog
  • Posts: 7,144
  • Joined: 07-September 06

Re: help me how to insert my selection 2 my bubble sort

Posted 29 January 2009 - 01:54 PM

Please don't post duplicate topics.

Merged.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1