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);
}
2.int i=(j=4,k=8,l=16,m=32); printf("%d", i); 输出是多少?
结果为: 32.
LENOVO笔试题
广博吧
人气:1.23W
周排行榜
- 1DELL笔试题
- 2QQ笔试题
- 3笔试题目
- 4JOHNSON笔试题
- 5笔试题(CICC)
- 6笔试题(NOTICE)
- 7NORTEL笔试题
- 8History笔试题
- 9Internet笔试题
- 10TEST笔试题
- 11OTIS笔试题
- 12笔试题(IBM)
- 13DELPHI笔试题
- 14Microsoft笔试题
- 15UT笔试题