华为面试题

C语言题,输入一个正整数,要求判断这个数是否是对称数(比如121,123321,1456541)。要求不能调用字符串库函数。... C语言题,输入一个正整数,要求判断这个数是否是对称数(比如121,123321,1456541)。要求不能调用字符串库函数。 展开
 我来答
goxigo
2009-10-23
知道答主
回答量:32
采纳率:0%
帮助的人:18.6万
展开全部
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>

int main(int argc, char* argv[])
{
while(1)
{
unsigned int nInt = 0;
scanf("%d",&nInt);

if(0 == nInt)
break;

char szDigit[32];
memset(szDigit,0,sizeof(szDigit));
unsigned int nIntT = nInt;

int nCount = 0;
while(nIntT > 0 && nCount < sizeof(szDigit) - 1)
{
szDigit[nCount] = nIntT % 10;
nIntT /= 10;
nCount++;
}

bool bRel = true;
for(int i = 0; i<nCount/2;i++)
{
if(szDigit[i] != szDigit[nCount - i - 1])
bRel = false;
}

if(bRel)
printf("%d is Y\n",nInt);
else
printf("%d is N\n",nInt);

}

system("pause");
return 0;
}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
创作者9Xg9aX6wAK
2013-09-13 · TA获得超过3688个赞
知道大有可为答主
回答量:3019
采纳率:25%
帮助的人:159万
展开全部
4.struct为关键字,是定意结构体的意思
6.全局变量,全局有效,局部变量,该函数内有效
8.16位
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
创作者vNrPcQOoWN
2013-08-28 · TA获得超过3888个赞
知道小有建树答主
回答量:3149
采纳率:30%
帮助的人:195万
展开全部
这就是华为面试的题目吗?是什么职位的啊?
4.struct为关键字,是定意结构体的意思
6.全局变量,全局有效,局部变量,该函数内有效
8.16位
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
创作者2PQy7M1yFD
2013-04-05 · TA获得超过3642个赞
知道大有可为答主
回答量:3138
采纳率:33%
帮助的人:247万
展开全部
#include
<stdio.h>
#include
<stdlib.h>
#include
<memory.h>
int
main(int
argc,
char*
argv[])
{
while(1)
{
unsigned
int
nInt
=
0;
scanf("%d",&nInt);
if(0
==
nInt)
break;
char
szDigit[32];
memset(szDigit,0,sizeof(szDigit));
unsigned
int
nIntT
=
nInt;
int
nCount
=
0;
while(nIntT
>
0
&&
nCount
<
sizeof(szDigit)
-
1)
{
szDigit[nCount]
=
nIntT
%
10;
nIntT
/=
10;
nCount++;
}
bool
bRel
=
true;
for(int
i
=
0;
i<nCount/2;i++)
{
if(szDigit[i]
!=
szDigit[nCount
-
i
-
1])
bRel
=
false;
}
if(bRel)
printf("%d
is
Y\n",nInt);
else
printf("%d
is
N\n",nInt);
}
system("pause");
return
0;
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
奇趣探秘者
2009-05-23 · TA获得超过3796个赞
知道大有可为答主
回答量:3053
采纳率:27%
帮助的人:158万
展开全部
1
一个
2
8
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(6)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式