Question: first judge whether the first is a negative number. If you remove the first symbol and determine whether the subsequent length is <= 12 and whether it is a number, then convert it into a number to see if it is in [a, B]. Pay attention to the-0 data.
If you do not judge whether the length is <= 12 and whether it is a number, convert it to a number to see if it is in [a, B].
# Include <cstdio> # include <cstring> char s [150], ss [150]; int A, B; long a, B; using namespace STD; int main () {While (gets (s )! = NULL )&&(~ Scanf ("% d", & B, & A) {A = A, B = B; gets (SS); int L = strlen (s ), flag = 1; if (L> 11 | L = 0) {puts ("no"); continue;} For (INT I = 1; I <L; I ++) if (s [I] <'0' | s [I]> '9') {puts ("no"); flag = 0; break ;} if (FLAG) {int flag1 = 1; long ans = 0; If (L = 1) {If (s [0] <'0' | s [0]> '9') {puts ("no"); continue ;} int now = s [0]-'0'; If (now> = B & now <= A) puts ("yes"); else puts ("no "); continue;} If (s [0] = '-') flag1 = 0; else if (s [0] <'0' | s [0]> '9') {puts ("n O "); continue;} If (flag1 & S [0] = '0') {puts (" no "); continue;} If (! Flag1 & S [1] = '0') {puts ("no"); continue;} If (flag1) for (INT I = 0; I <L; I ++) ans = ans * 10ll + s [I]-'0'; else {for (INT I = 1; I <L; I ++) ans = ans * 10ll + s [I]-'0'; ans =-ans;} If (ANS> = B & Ans <=) puts ("yes"); else puts ("no") ;}} return 0 ;}// pay attention to the single symbol and 0, and the problem of over int in computing
HDU 5059 help him