LENOVO筆試題
1.設(shè)計(jì)函數(shù) int atoi(char *s),
LENOVO筆試題
。int atoi(char *s)
{
char sign;
char sign_val = 1;
int val = 0;
int n = 0;
/* skip spaces */
while (isspace(*s))
++s;
if (*s == '-' || *s == '+')
/* skip '-' and '+' sign */
{
sign = *s;
if (sign == '-')
sign_val = -1;
++s;
}
/* when goes here, it is not space or sign */
while ((*s != '\0') && isdigit(*s))
{
val = 10 * n + (*s - '0');
n = val;
s++;
}
if (*s != '\0')
{
printf("non digit in your input!!\n");
exit(-1);
}
/* non error occured */
return (sign_val * val);
}
2.int i=(j=4,k=8,l=16,m=32); printf("%d", i); 輸出是多少?
結(jié)果為: 32.
【LENOVO筆試題】相關(guān)文章:
2.360筆試題目
3.360筆試題目