Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 10-03-2005, 01:56 PM   #1 (permalink)
Dina
Registered User
 
Join Date: Oct 2005
Posts: 1
Dina is on a distinguished road
Unhappy writing a code of a program that sorts numbers

hi all, im new to this website ,also im a new user of VB.net.
please i need your help in writing a code of a program that sorts 3 numbers using if statments.
please help me because i feel that im lost and cant get the logic of that program
thanx alot
Dina is offline   Reply With Quote
Old 10-06-2005, 05:33 PM   #2 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Okay I don't know any vb much less dot net, but if you think about the algorithm you should be able to formalize the code. If A is greater than B, then if C is greater than A you've sorted the number properly right? The else cases just do a few more comparisons to determine alternate orders. In psuedo-code
Code:
if ( a > b )
{
     if ( c > a )
     {
	  return c a b;
     }
     else
     {
	  if ( c > b )
	  {
	       return a c b;
	  }
	  else
	  {
	       return a b c;
	  }
     }
}
else
{
     if ( c > b )
     {
	  return c b a;
     }
     else
     {
	  if ( c > a )
	  {
	       return b c a;
	  }
	  else
	  {
	       return b a c;
	  }
     }
}
Let me reinforce that this isn't legal vb code (I don't think) but it should illustrate the algorithm.
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to convert program to pseudo code...please help lukmanpatel Standard C, C++ 1 04-02-2005 05:47 AM
Help with a simple program C++noob Standard C, C++ 1 03-24-2005 04:31 PM
Cisco Code breaking sde Code Newbie News 0 05-21-2004 08:10 AM


All times are GMT -8. The time now is 10:06 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting