Title: an 8-bit integer, its each serial number of the first two represent one letter in the alphabet (00-25), write a program, enter an 8-bit integer (fill in the front of the eight 0) enough, according to the above rules transform it into a four-letter word, enter 01112004, for example, the output blue, Answer: #include using namespace std; Int main () {char a, b, c, d; Int f; Cin> f; D=f % 100; C=100% f/100; B=f/100 10000%; A=f/100 1000000%; Coutreturn 0; }
My method is more troublesome, but can still use it
CodePudding user response:
Your approach can, is slightly clumsy, can use a loop to do Or you can save the input integer into a character array For example, Char buf [9]. Sprintf (buf, "% d" 08, f); Then two traverse character array calculate can