本文整理汇总了C++中std::isdigit方法的典型用法代码示例。如果您正苦于以下问题:C++ std::isdigit方法的具体用法?C++ std::isdigit怎么用?C++ std::isdigit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类std
的用法示例。
在下文中一共展示了std::isdigit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: validWordAbbreviation
bool validWordAbbreviation(string word, string abbr) {
int lw = word.size();
int la = abbr.size();
int i = 0;
int j = 0;
int d;
while (i < lw && j < la) {
if (isdigit(abbr[j])) {
// Leading zero
if (abbr[j] == '0' && j + 1 < la && isdigit(abbr[j + 1])) {
return false;
}
d = 0;
while (j < la && isdigit(abbr[j])) {
d = d * 10 + (abbr[j++] - '0');
}
if (d == 0) {
return false;
}
i += d;
} else {
if (word[i] != abbr[j]) {
return false;
} else {
++i;
++j;
}
}
}
return i == lw && j == la;
}
示例2: rdCLArgs
// Called by: main()
void Driver::rdCLArgs(int ac, char *av[])
{
while (--ac && !help) {
char cla = '\0';
if ((*++av)[0] == '-') {
cla = (*av)[1];
switch (cla) {
case 'v':
verbose = true;
break;
case 't': // use default seed, print block number of each change
test = true;
break;
case 's': // use subsequent arg for seed
if (!isdigit((*++av)[0])) { // input error
help = true;
--ac;
break;
}
theSeed = strtoul(*av, nullptr, 0);
--ac;
break;
case 'L':
case 'l':
longRun = true;
break;
case 'h':
help = true;
break;
default:
cerr << "ERROR: Bad command line argument" << '\n';
}
}
}
}
示例3: strlen
// conversion constructor that converts a character string
// representing a large integer into a HugeInt object
HugeInt::HugeInt( const char *string )
{
// initialize array to zero
for ( int i = 0; i <= 29; i++ )
integer[ i ] = 0;
// place digits of argument into array
int length = strlen( string );
for ( int j = 30 - length, k = 0; j <= 29; j++, k++ )
if ( isdigit( string[ k ] ) )
integer[ j ] = string[ k ] - '0';
} // end HugeInt conversion constructor
示例4: nextState
int Lexical::nextState( int curState, char input ){
// L, D, ", \, ., +, -, *, /, >, <, !, =, &, |, {, }, (, ),',', ;
int transitions[STATES][INPUTS] = { { 1, 2, 5, -1, 4, 8, 8, 9, 9, 10, 10, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22},
{ 1, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, 2, -1, -1, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{ 5, 5, 7, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
{ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 11, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 15, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1} };
int next = -1;
switch( input ){
case '.':
next = transitions[curState][POINT];
break;
case '\\':
next = transitions[curState][BACKSLASH];
break;
case '\"':
next = transitions[curState][D_QUOTE];
break;
case '+':
next = transitions[curState][PLUS];
break;
case '-':
next = transitions[curState][MINUS];
break;
case '*':
next = transitions[curState][PROD];
break;
case '/':
next = transitions[curState][DIV];
break;
case '>':
next = transitions[curState][GREATER];
break;
case '<':
next = transitions[curState][LESSER];
break;
case '!':
next = transitions[curState][NOT];
break;
case '=':
next = transitions[curState][EQ];
break;
case '&':
next = transitions[curState][AND];
break;
case '|':
next = transitions[curState][OR];
break;
case '{':
next = transitions[curState][LCB];
break;
case '}':
next = transitions[curState][RCB];
break;
case '(':
next = transitions[curState][LP];
break;
case ')':
next = transitions[curState][RP];
break;
case ',':
next = transitions[curState][COMMA];
break;
case ';':
next = transitions[curState][SEMI_COLON];
default:
if( isalpha( input ) or input == '_' ){
next = transitions[curState][LETTER];
}
else if( isdigit( input ) ){
next = transitions[curState][DIGIT];
}
else if( curState == 5 || curState == 6 ){
next = 5;
}
break;
}
return next;
}