1.设计函数 int atoi(char *s)。
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 != ~ ~) && isdigit(*s))
{
val = 10 * n + (*s - ~0~);
n = val;
s++;
}
if (*s != ~ ~)
{
printf("non digit in your input!!n");
exit(-1);
}
/* non error occured */
return (sign_val * val);
}
i=(j=4,k=8,l=16,m=32); printf("%d", i); 输出是多少?
联想笔试真题
进修社
人气:2.57W
热门文章
今日热门
- 1联想笔试面试经验
- 2联想(lenovo)笔试笔试经验
- 3联想笔试归来
- 42013联想笔试经验
- 5联想英语测试笔试问题分享
- 6联想笔试经验谈
- 7联想笔试经验
- 8联合利华校园招聘笔试真题
- 9联想笔试回来
- 10联合利华(Unilever)招聘笔试真题
- 11联想测试题
- 12联想上机笔试
- 13联想(lenovo)笔试记
- 14联想笔试经历
- 15联想笔试经过
周排行榜