Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: CSC105 Assignment

  1. #11
    Administrator asylu3's Avatar
    Join Date
    Jun 2000
    Location
    Thailand
    Posts
    3,557


    Re: CSC105 Assignment

    เวลา post โค้ดให้ใช่แทคนี้นะครับจะได้ดูง่ายๆ

    [src] ..your code ..[/src]

  2. #12
    Junior Member
    Join Date
    Jun 2004
    Location
    Thailand
    Posts
    26


    Data Structure Exercise 1

    Here is the code that transform number in decimal to binary and also count number of 1's.
    This program use recursive method.
    [src]
    public class Binary
    {
    public static void Convert(int n)
    {
    if (n<=1)
    System.out.print(n);
    else
    {
    Convert(n/2);
    System.out.print(n%2);
    }
    }
    public static int count(int num)
    {
    if (num<=1)
    return num;
    if (num%2==1)
    return count(num/2)+1;
    return count(num/2);
    }
    public static void main(String[] args)
    {
    int num = 13;
    System.out.print("=> You input "+num+" in decimal and in binary is :");
    new Binary().Convert(num);
    System.out.println("");
    System.out.println("It has "+ count(num)+" of 1's");
    }
    }[/src]

  3. #13
    Senior Member
    Join Date
    Jul 2004
    Location
    Bangkok
    Posts
    187


    Re: CSC105 Assignment

    [code]

    public static void Convert(int n)

    {


Page 2 of 2 FirstFirst 12

Similar Threads

  1. Replies: 0
    Last Post: 08-12-2008, 11:27 PM
  2. Replies: 0
    Last Post: 22-11-2008, 05:04 PM
  3. Replies: 16
    Last Post: 30-08-2008, 01:00 AM
  4. NEW Assignment CSC105
    By massiah in forum Java
    Replies: 4
    Last Post: 04-11-2004, 11:37 PM
  5. assignment aj udom
    By armano in forum Announcement
    Replies: 4
    Last Post: 02-03-2003, 06:03 PM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •