Share on Google+Share on Google+

Kavinda Chathuranga
Algorithm
1 Answer(s)      6 years and 5 months ago
Posted in : Java Beginners

How can i write a code for sort ascending order to ten given numbers.

Thank you

Ads

View Answers

November 5, 2010 at 5:07 PM


Receive the numbers into an array. double num[10]. or int num[10].

You then need to traverse the array elements and swap them into the desired order.

int temp = 0;   
for (int j=0; j<10; j++) {   
   for (int i=0; i<9; i++) {            
      if (num[i] > num[i+1]) {       
          temp = num[i];   
          num[i] = num[i+1];  
          num[i+1] = temp;   
  } 
}

[email protected]










Related Tutorials/Questions & Answers:
algorithm
algorithm  convert this algorithm to java code IsSample_PAS: 1.for every attribute value aj belongs to ti do begin (here aj=1,2...,ti=1,2..) 2.if(CF... false; (this is algorithm from ieee paper QUALITY AWARE SAMPLING AND ITS
algorithm
algorithm  Hi all, i have a task which is create an algorithm from a java code.and i need help from u guys to check on my algo put a comment... on this matter... thanks a lot. here is my algorithm: > Input
Advertisements
Algorithm - Java3D
Algorithm  what is NaiveSimilarity algorithm? How we use this algorithm to recognize a face in face recognition (using Java)? which is the steps involved in this? Which is the database used to store an image
efficiency of an algorithm
efficiency of an algorithm  how can we calculate the best or worst case efficiency of an algorithm
efficiency of an algorithm
efficiency of an algorithm  how can we calculate the best or worst case efficiency of an algorithm
C4.5 ALGORITHM
C4.5 ALGORITHM  I am doing my project in data mining.Any body having code for C4.5 decision tree algorithm in java with output.Help me Friends
Conflation Algorithm
Conflation Algorithm  implementation of conflation algorithm is possible using java?? conflation requires file handling a text contains stop words(is,or,and,.,)remove this words remove suffix(ing,ed..) remove equal words count
Problem analysis and algorithm design (i.e.: flowchart, algorithm)
Problem analysis and algorithm design (i.e.: flowchart, algorithm)  Problem analysis and algorithm design (i.e.: flowchart, algorithm)for this question.Write a Java program that prompt user to input a number of students
Algorithm - Java Beginners
Algorithm  (a) Describe the manual procedure, if one has to use the above algorithm and the first element as the pivot to sort the sequence... the algorithm you want to use to sort the sequence. Thanks
Asymmetric algorithm - Java Beginners
Asymmetric algorithm  hybrid Digital image embedding using invisible watermarking with rsa and dct algorithm? please send me this project with source code........ regards subramanian
How to write a rsa algorithm using thread
How to write a rsa algorithm using thread   Hi... This my **rsa algorithm sequential code..can u anyone plz change/convert to concurrent...("Time required for sequential rsa algorithm:"+(endtime-starttime)+"millisecond
implementing an algorithm using multi threads - Java Beginners
implementing an algorithm using multi threads  Hi i need to implement an algorith in multi threads.Algorithm has data dependency so i need to pass data from one thread to another thread. I am posting my algorithm which needs
pattern matching --four way technique........brute force algorithm
pattern matching - four way technique  Hi, here's my question.. I am trying to implement pattern matching using brute force algorithm where I am trying to apply four way technique to search a given pattern in a text.in
Google Penguin Algorithm update issues and How to Recover
of the year 2013 and will "go deeper". Like all other Google algorithm updates
Google Panda 4.0 is rolling out
the search engine, the latest version of search engine algorithm. Google Panda... the previous algorithm update in last year this one also going to hit many... content the algorithm will actually help to avoid the clutter and get better
C array sort example
the implementation of quicksort algorithm to sort the elements of an array. Syntax
Selection Sort in Java
. In selection sorting algorithm, the minimum value in an array is swapped... sort is probably the most spontaneous sorting algorithm. Selection sort... in Java. In selection sort algorithm, first assign minimum index in key as index
Google Penguin 3.0 Launched
algorithm. According to the Google this update will cheer up the webmasters... websites whose ranking is increased and they are celebrating. This algorithm
Google Penguin Update vs. Black Hat SEO
, but it is more important as this new algorithm of Google is to make web user experience... by this new algorithm and this time the target is mainly the spammers and bad links... through its webmaster guidelines and algorithm updates to put it into actual
Insertion Sort Java
Insertion Sort in Java is an algorithm that is used to sort integer values. It can be implemented very easily and is efficient for small data sets. However.... In insertion sorting, algorithm divides the elements in two parts, one which
Google Penguin 2.0: Real SEO Strategy to avoid Penalty
the potential threat of penalty by Penguin 2.0 algorithm update, SEO's... the situation. Following the strictness of Google in the recent Penguin algorithm update... to overcome the threat of Penguin algorithm update penalty and hence followed
JDBC Nested Resultset
JDBC Nested Resultset       The JDBC Nested Result Set  is the simplest join algorithm. In this case for each tuple in the outer join relation, the entire inner
C# Programming Books
C# Programming Books         Data Structure and Algorithm All rights reserved. No part of this publication may be reproduced
Quick Sort in Java
Quick sort in Java is used to sort integer values of an array. It is a comparison sort. Quick sort is one of the fastest and simplest sorting algorithm...) and in the worst case is Θ(n2). In quick sort algorithm, an element
How to Save Your Site from Google Penguin Update
Every Google algorithm has created some uproar among the websites... deep treading algorithm to strike more websites with detrimental practices... already following previous Google algorithm updates, but churned or slightly
Google Penguin Update at a Glance
algorithms latest Google Penguin update is just the algorithm geared towards putting... algorithm update followed by cloaking, duplicate content, bad link scheme
Google Penguin Update 2013
Google Penguin is an algorithm that Google uses to restrict spam websites or blogs. Till today, Google has rolled out three updates to original Google Penguin. With Google Penguin latest update, it is trying to improve the quality
10 Ways Google Penguin Update will affect SEO
Google Penguin update, the SEO algorithm from Google that already... becoming targets of Google webmaster guidelines and algorithm updates. One... if it had been a decade before, but with new Google algorithm you cannot get away
How to Recover from Google Penguin Effects
in regard to the new Google algorithm to come into terms with the reality... question marks on you. As per the new Google algorithm heaping up huge amount... after new Google algorithm update. Reduce inappropriate keyword density
Tutorials   
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code

Ads

 
Advertisement null

Ads