Ten etiquette into a small procedure for two, eight, and hexadecimal

xiaoxiao2021-03-05  49

A program written by a help school, huh, it is very simple.

#include / ********* Define a credit function ************* / void trans (int n, int base) {int store [ 100]; int TMP1 = N, TMP2; INT i = 0; while (tmp1> = base) // cycle takes the remainder {TMP2 = TMP1% Base; TMP1 = TMP1 / BASE; Store [i ] = TMP2; IF (TMP1 <= base) store [i] = TMP1;} for (int J = i; j> = 0; j--) // (Store [J] <10) {COUT << STORE [ J];} else {switch (Store [J]) // 16 The number represented by the letters represented by the letter {CASE 10: COUT << 'a'; Break; Case 11: COUT << 'B'; Break; Case 12: COUT << 'C'; Break; Case 13: COUT << 'D'; Break; Case 14: COUT << 'E'; Break; Case 15: COUT << 'F'; Break;}} } Cout << endl;

Void main () {int Num, base; cout << "Please enter a decimal number and the number of inputs to the converted" << endl; cin >> Num >> Base; Trans (Num, Base);

转载请注明原文地址:https://www.9cbs.com/read-36658.html

New Post(0)