猿问

定义一个将十进制转化为16进制

)定义一个将十进制数转换成十六进制数的函数void dec_to_hex(int n),该函数的功能是将参数中的十进制数以十六进制方式输出。在主函数输入一个十进制整数,然后调用dec2hex()输出对应的十六进制数。 #include <stdio.h> _________⑴__________; // dec_to_hex函数的声明 int main() { int n,rem; printf("Enter n: "); scanf("%d",&n); printf("\n十进制数:%d 转换为十六进制数是:",n); ______⑵_______; // dec_to_hex函数的调用 printf("\n"); return 0; } void dec_to_hex (int n) { char num[20]; int rem,i=0; do { rem=n%16;   //存放余数 n=n/16; if (rem<10) _____⑶_____ //10以内的数字转换成对应的字符存放在字符数组num[]中 else ____⑷_____ //10以上的数字转换成对应的字符存放在字符数组num[]中 }while(n>0); for(i=i-1;i>=0;i--) printf("%c",num[i]); printf("\n"); }
SUNMOON1
浏览 2096回答 1
1回答

慕瓜9220888

TRKTIJQNQQIMZYYFWGNFSBYCZJSCBTJLCJZJUCDCKBOFWXFODGNKAJEFYXZQHEOPJFBZWXUIGEKUWQGWVQXQFXYWAXDNWCEVCKGTJYPTWPAFXAIPNVJSNWGEQHIOMGOGDZOPFGSDOTKCYFRVYIKJLBHUHQUPQVBENNKIORQQDKLTRGZVCTTUFBGPYFFZDIDWIREBLMMHOHNTHHBQVWYRYEBMKSIAGWSFJTLUNMTQIJQCEXMDKKUFGCBXAROIVKZYHOFSDKBWYOOYZJVTWDCWNKUMQJIBSSSLQENMBYFSDXPONFWWQKLMSRGFCJKGOXWPWTDUMEDTXKOOYKYNWMBBBMKCGVOOFVQBGLKOVMJQSKNCBYFCTFHQYYYFPJRFUXWNXHBMUTFONWDKMKQYYELCJTFEDHHYPXTODTYCTDKZAJIBSIPJQIUDFWGFPZQSHPYIRHYGZIQWTCSKSKPRMVEEJEDVDQDCXLSKMEEHQNRSNWURHUDLBKZUEAEQZMHWSGSMDHZNJJUIIJPBIVPDRAHAVLBGQHOOKCLUTNEEOWMFOWTUUVONMLUUOVFTRBKLCSMDASUDCJAXEMHAFEDKRBNVKTVM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; printf("Enter n: "); scanf("%d",&n); printf("\n十进制数:%d 转换为十六进制数是:",n); dec-to-hex(n) ;// dec_to_hex函数的调用 printf("\n"); return 0; } void dec_to_hex (int n) { char num[20]; int rem,i=0; do { rem=n%16; //存放余数 n=n/16; if (rem<10) num[i++]=‘0’+rem;//10以内的数字转换成对应的字符存放在字符数组num[]中 else num[i++]=‘A’+(rem-10);//10以上的数字转换成对应的字符存放在字符数组num[]中 }while(n>0); for(i=i-1;i>=0;i--) printf("%c",num[i]); printf("\n"); }
随时随地看视频慕课网APP
我要回答