shwq.net
当前位置:首页 >> 判断一字符串是否是回文数,如121,12321,ABA等(... >>

判断一字符串是否是回文数,如121,12321,ABA等(...

Var s:string; i:longint;Begin readln(s);//输入字符串 For i:=1 to length(s) do if s[i]s[length(s)-i+1] Then Begin//判断字符串正数第i位和后数第i位是否相同 writeln('False');//若不相同,则不是回文串 halt;//结束程序 End; writeln('Tr...

不难吧 #include using namespace std; int main() { char str[100]; cin >> str; int n = strlen(str); int i; for (i = 0; i < n / 2; i++) { if (str[i] != str[n - i - 1]) { cout

#include int main() {int x,y,x1; scanf("%d",&x); x1=x; for(y=0;x>0;x/=10) y=y*10+x%10; if(y==x1) printf("yes"); else printf("no"); return 0; }

你写的太复杂了,很容易错#include void main() { int t,s=0,n; printf("输入数字:"); scanf("%d",&n); t=n; while(t) s=s*10+t%10,t/=10; if(s==n)printf("是\n"); else printf("不是\n"); } 思路是把一个数倒过来,如果还等于原数,就是

#includeint main(){long int m;int a,b,c,d,e;//代表个十百千万printf("please intput a number:\n");scanf("%d",&m);if(9999

program ex12b(input,output); var a,b,j,k,l,n:longint; sth:string; l1,l2,i,d1,d2:integer; function power(c,d:integer):longint; var m:integer; begin power:=1; for m:=1 to d do begin power:=power*c; end; end; begin assign(input,'p...

如果确定为五位数,要用数组的话:public static void chekc(String number) { char[] numArr = number.toCharArray(); if (numArr[0] == numArr[4] && numArr[1] == numArr[3] && numArr[2] == numArr[1] +1) { System.out.println(number + "...

define _CLANUAGE_ ifndef _CLANUAGE_ define _CLANUAGE_ include lt;stdlib.h; include lt;stdio.h; endif ifndef _CPP_ define _CPP_ include lt;iostream; using namespace std; endif /* 操作结果: 0-非回文,1是回文 */ int hws(int n){ in...

给楼主提个思路,先把这个数字的反转,然后比较,如果相等则是回文数,否则不是,比如12345反转为54321,两者不相等,不是回文数, 程序: #include int main() { int Ishuiwen(int a); long a=12321; if (Ishuiwen(a)) { printf("%d是回文数\n"...

#include #include int main() { char a[10]; while(scanf("%s",a)==1) { int len=strlen(a); int i,sum=0; for(i=0;i

网站首页 | 网站地图
All rights reserved Powered by www.shwq.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com