/* programs fill in the blanks, don't change related to the input and output statements,
Input a number of consecutive # at the end of the string (the length of the string does not exceed 80), in case # # all input end,
Do the following with each string: filter after all the non hexadecimal character, form a new string (hexadecimal form), then it is converted to a decimal number after output,
Example: the brackets is
Input:
10 + 1 + # # # - # Pf4 (three consecutive input string)
Output:
16
3905
10 */
# include
# define MAXLEN 80 Int main () {int I, k; Long number; Char ch, oldch, STR [MAXLEN], num [MAXLEN]; Oldch=' '; While ((ch=getchar ())!='#' | | oldch!='#') { k=0; While (ch!='#' & amp; & k { STR [k++]=ch; ch=getchar(); } Oldch='#'; STR [k]=0; /* -- -- -- -- -- -- -- -- - */ Printf (" % ld \ n ", number). } } CodePudding user response:
Printf (" % ld \ n ", number). You are not the assignment, the number,, CodePudding user response:
reference 1st floor fireyou response: printf (" % ld \ n ", number). You are not the assignment, the number,, Is to fill in the blanks, this is about architecture CodePudding user response:
# include # define MAXLEN 80 Int main () { Int I, k; Long number; Char ch, oldch, STR [MAXLEN], num [MAXLEN]; Oldch=' '; While ((ch=getchar ())!='#' | | oldch!='#') { k=0; While (ch!='#' & amp; & k { STR [k++]=ch; ch=getchar(); } Oldch='#'; STR [k]=0; /* -- -- -- -- -- -- -- -- - */ # define isDigit (x) (x) & gt;='0' & amp; & (x) & lt;='9') # define isA2F (x) (x) & gt;='A' & amp; & (x) & lt; ) ='F'# define isa2f (x) (x) & gt;='a' & amp; & (x) & lt; ) ='f'# define isXDigit (x) (isDigit (x) | | isA2F (x) | | isA2F (x)) Number=0; for (i=0; I & lt; k; I++) { If (isXDigit (STR [I])) Num=STR [number++] [I]; } Num [number]=0; K=number; Number=0; for (i=0; I & lt; k; I++) { If (isDigit (num [I])) Number=number * 16 + (num [I] - '0'); Else if (isA2F (num) [I]) Number 16 + 10=number * + (num [I] - 'A'); Else if (isa2f (num) [I]) Number 16 + 10=number * + (num [I] - 'a'); } Printf (" % ld \ n ", number). } } CodePudding user response:
Thank you, although a little look not to understand, but still want to thank you CodePudding user response:
Input a number of consecutive # by the end of the string ( the length of the string does not exceed 80 ), encounter # # all input end, CodePudding user response:
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html