LENOVO笔试题
1.设计函数 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); 输出是多少?
结果为: 32.
【LENOVO笔试题】相关文章:
1.lenovo笔经
2.360笔试题目
3.360笔试题目