| A Question of C++ Programming? |
★★★ |
| A Question of C++ Programming? |
|
作者:软件开发… 文章来源:阿达 更新时间:2008-4-9 0:26:55  |
|
A Question of C++ Programming?
A palindrome is a number or a text phrase that reads the same backwards as forwards. For example, each of the following five-digit integers is a palindrome:12321,55555,45554 and 11611. Write a program that reads in a five-digit integer and determines whether it is a palindrome.(Hint:Use the division and modulus operators to separate the number into its individual digits.)
#include "string.h"
#include "stdio.h"
#define MAX 100
bool fun(char *str)
{
int len,i;
len=strlen(str);
for(i=0;i<len/2;i++)
if(str[i]!=str[len-1-i])
return false;
return true;
}
void main()
{
char s[MAX];
gets(s);
if(fun(s))
printf("yes");
else
printf("no");
}
揪错 ┆ ┆ 举报
提问者对答案的评价:
|
| 文章录入:admin 责任编辑:admin |
|
上一篇文章: vb程序不能运行
下一篇文章: C和C++有区别吗? |
|
|
|
|
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |