请参考以下程式,请用function及回圈改写此程式,
令此程式能输入0~65535并将之转成十六进制。
并使程式能能执行以下输入和输出

Ex1:input:0
     Output:0000
Ex2:input:65535
     Output:FFFF

程式:
-------------
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
    int a, b;
    printf("請輸入一筆十進制之正整數(0~255之間):");
    scanf("%d", &a);
    if( a > 255 || a < 0)
    {
        printf("輸入範圍錯誤!!\n");
    }
    else
    {
        printf("十進制值%d轉成十六進制值為:", a); 
        b = a / 16;
        switch(b)
        {
            case 10:
                 printf("A");
                 break;
            case 11:
                 printf("B");
                 break;
            case 12:
                 printf("C");
                 break;
            case 13:
                 printf("D");
                 break;
            case 14:
                 printf("E");
                 break;
            case 15:
                 printf("F");
                 break;
            default:
                 printf("%d", b);
        }
        b = a % 16;
        switch(b)
        {
            case 10:
                 printf("A");
                 break;
            case 11:
                 printf("B");
                 break;
            case 12:
                 printf("C");
                 break;
            case 13:
                 printf("D");
                 break;
            case 14:
                 printf("E");
                 break;
            case 15:
                 printf("F");
                 break;
            default:
                 printf("%d", b);
        }
        printf("\n");
    }
    
    system("pause");
    return 0;
}
------------

跪求了!!!