| |

VerySource

 Forgot password?
 Register
Search
View: 1449|Reply: 10

consult

[Copy link]

1

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-1-7 15:00:01
| Show all posts |Read mode
Please print out the hexadecimal form of a decimal integer by shifting. Tip: The integer is shifted and debited every 4 binary digits, and the result is a hexadecimal number. Then use one of the following three methods (As a job, each method is required ) Calculate the hex form of a hexadecimal value:
1) The value between 0-9 is directly added to the character '0', and the value above 9 is subtracted from 10 and then the character 'A' is added
2) Define an array that contains the characters 0-F, and then use the value to be calculated as the index number of the array to obtain its corresponding hexadecimal data.
3) The Character.forDigit static method can convert a hexadecimal number to its corresponding character representation, for example, returns the character 'F' based on the value 15.
Reply

Use magic Report

1

Threads

51

Posts

32.00

Credits

Newbie

Rank: 1

Credits
32.00

 China

Post time: 2020-1-15 22:18:01
| Show all posts
It's not difficult or annoying. I don't know which step of LZ ~~ Don't throw a big question out.
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-8-20 16:30:01
| Show all posts
up
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-20 16:45:01
| Show all posts
Schools will have this kind of garbage problem, bs...
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Invalid IP Address

Post time: 2020-8-20 17:00:01
| Show all posts
School will have this kind of garbage problem
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-20 18:30:01
| Show all posts
Is a bit annoying
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-8-21 23:45:01
| Show all posts
Is decimal to hexadecimal?

public class DecToHex {

public static char table[]={'0','1','2','3','4','5','6','7','8','9','A ','B','C','D','E','F'};

    public static void main(String[] args)
    {
    int sourceDec=Integer.parseInt(args[0]);
    int length=0;
    int[] digits=new int[20];
    while(sourceDec>=16)
    {
    digits[length++]=sourceDec%16;
    sourceDec/=16;
    }
    digits[length]=sourceDec;
    for(int i=length;i>=0;i--)
    {
    System.out.print(table[digits[i]]);
    }
    }

}
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-22 00:00:01
| Show all posts
up
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-8-22 00:30:02
| Show all posts
Such things are annoying to watch.
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-8-22 01:00:02
| Show all posts
public class DecToHex{

public static char table[]={'0','1','2','3','4','5','6','7','8','9','A ','B','C','D','E','F'};

    public static void main(String[] args)
    {
    int sourceDec=Integer.parseInt(args[0]);
    int length=0;
    int[] digits=new int[20];
    while(sourceDec>=16)
    {
    digits[length++]=sourceDec&0x0000000f;
    sourceDec>>=4;
    }
    digits[length]=sourceDec;
    for(int i=length;i>=0;i--)
    {
    System.out.print(table[digits[i]]);
    }
    }

}
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list