编写一个子程序,从键盘接受一个无符号十进制数,在显示器上以十六进制形式显示其值

来源:百度知道 编辑:UC知道 时间:2024/06/30 18:33:46

安装一个proteus 仿真软件, 把里面自带的例子,

用c#写的,你看看。
using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int j = 0;
int[] array = new int[16];
int[] array1 = new int[4];
for (int i = 0; i < 16; i++)
array[i] = -1;
string str = Console.ReadLine();
int num = Convert.ToInt32(str);
while (num != 0)
{
array[j] = num % 2;
j = j + 1;
num = num / 2;
}

for (j = 0; j < 16; j++)
{
if (array[j] == -1)
array[j] = 0;
}
j = 0;
for (int x = 0; x < 16;