How to determine 123 is 123 characters of several digital character string?
CodePudding user response:
Description to complete
CodePudding user response:
If the variable==49
CodePudding user response:
Do a array, digit [10]={0}
Each character of the string STR do a loop, the if (0 & lt;=STR [I] & amp; & STR [I] <=9) digit [STR [I] - '0']] + +;
That is to say, if there is a string '3', the digit [3] + +;
Loop again all string interrupt letters have results after
Just 123 example, digit [1], [2], [3] value is not zero, so the character is composed of 1, 2, 3
CodePudding user response:
Fun
reference 3 floor response: do an array, digit [10]={0} Each character of the string STR do a loop, the if (0 & lt;=STR [I] & amp; & STR [I] <=9) digit [STR [I] - '0']] + +; That is to say, if there is a string '3', the digit [3] + +; Loop again all string interrupt letters have results after 123 example, digit [1], [2], [3] value is not zero, so the character is composed of 1, 2, 3 I described not clear before, I wanted to ask if I input the number 123456789 in the binary is it when a number is divided into several parts, like a string of "12345" is how to use the binary storage CodePudding user response:
It depends on how you receive the number of The scanf (" % d ", & amp; n); It is a binary integer If is the scanf, specify % s, then put in is a string All the data in a digital computer is a binary representation, if divided into several parts, type of data that is based on how many bytes of the If char is a byte, the input hot big number, can only modulus If the int is 4 bytes, the largest can accommodate 10, put you this 123456789 is still no problem If is float, and 4 bytes, but only six to seven significant figures, reservation is the result of the 1.23456 or 1.23457 * 10 ^ 9 If it is double, or long double digital longer effectively, but also not necessarily can accurately express If it is a string, is 10 bytes, 1 ~ 9 each one byte, and do a byte string terminator '\ 0' CodePudding user response:
Fun reference 5 floor response: it depends on how you receive the number of The scanf (" % d ", & amp; n); It is a binary integer If is the scanf, specify % s, then put in is a string All the data in a digital computer is a binary representation, if divided into several parts, type of data that is based on how many bytes of the If char is a byte, the input hot big number, can only modulus If the int is 4 bytes, the largest can accommodate 10, put you this 123456789 is still no problem If is float, and 4 bytes, but only six to seven significant figures, reservation is the result of the 1.23456 or 1.23457 * 10 ^ 9 If it is double, or long double digital longer effectively, but also not necessarily can accurately express If it is a string, is 10 bytes, 1 ~ 9 each one byte, and do a byte string terminator '\ 0' That if it is as a string "12345678987654321" how to store? Digital storage or one?" 123 "? CodePudding user response:
Stdin Buffer According to the character format one by one store Pay attention to character is not string No 0 at the end CodePudding user response:
If it is according to the string input, then according to the characters of the storage Such as the first word JieCun '1', corresponding ascii49, is 49 binary, the second character '2', corresponding ascii50, is to save 50 binary,... And so on CodePudding user response:
Char buffer [100]. The scanf (" % s ", buffer); String to receive buffer, the buffer is a char array, so this is a string of Numbers in ASCII mode, one character one byte is stored in the array