ZOJ 1078 Palindrom Numbers
来源:互联网 发布:数据分析比赛 编辑:程序博客网 时间:2024/04/20 07:24
--------------------------------------------------------------------------------Time Limit: 1 Second Memory Limit: 32768 KB --------------------------------------------------------------------------------Statement of the Problem We say that a number is a palindrom if it is the sane when read from left to right or from right to left. For example, the number 75457 is a palindrom.Of course, the property depends on the basis in which is number is represented. The number 17 is not a palindrom in base 10, but its representation in base 2 (10001) is a palindrom.The objective of this problem is to verify if a set of given numbers are palindroms in any basis from 2 to 16.Input FormatSeveral integer numbers comprise the input. Each number 0 < n < 50000 is given in decimal basis in a separate line. The input ends with a zero.Output FormatYour program must print the message Number i is palindrom in basis where I is the given number, followed by the basis where the representation of the number is a palindrom. If the number is not a palindrom in any basis between 2 and 16, your program must print the message Number i is not palindrom.Sample Input17190Sample OutputNumber 17 is palindrom in basis 2 4 16Number 19 is not a palindrom 简单题。题目的意思很简单,就是给出一个数求它在不同进制下是否为回文数.几个问题:1,k一开始放循环外面,程序一直不出结果2.循环里面和外面的标志器不一样Code :#includeint main(){ int n,k,l,sign,i,j; while(scanf("%d",&n)&&n) { int b[17]={0}; int c[50]; for(i=2;i<=16;i++) { l=0; sign=1; k=n;//k=n放在循环里面,防止被覆盖!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! while(k) { c[l++]=k%i; k=k/i; } for(j=0;j<=l/2;j++)//l不能是l+1 if(c[j]!=c[l-j-1]) sign=0; if(sign==1) b[i]=i; } sign=1;//重新定义标志位,前面的被覆盖,sign 取的永远都是i=16时的值。 for(i=2;i<17;i++) if(b[i]!=0) sign=0; if(sign) printf("Number %d is not a palindrom/n",n); else { printf("Number %d is palindrom in basis",n); for(i=2;i<17;i++) if(b[i]) printf(" %d",b[i]); printf("/n"); } } return 0;}
- ZOJ 1078 Palindrom Numbers
- zoj 1078 Palindrom Numbers
- ZOJ 1078 :Palindrom Numbers
- zoj 1078 Palindrom Numbers
- ZOJ 1078-Palindrom Numbers
- zoj 1078 Palindrom Numbers
- ZOJ--1078:Palindrom Numbers
- ZOJ Problem Set - 1078(Palindrom Numbers)
- ZOJ 1078 Palindrom Numbers
- ZOJ Problem Set - 1078 Palindrom Numbers
- ZOJ Problem Set - 1078||Palindrom Numbers
- ZOJ Problem Set - 1078 Palindrom Numbers
- 1078 Palindrom Numbers
- Palindrom Numbers
- Palindrom Numbers
- Palindrom Numbers
- zoj1078 Palindrom Numbers
- fjnu 1827 Palindrom Numbers
- 招商银行的网上银行个人专用版乱码解决办法
- 你不可不知的Mango — 开发者篇(4)
- 奔袭的美丽-2011年端午广州行
- 某种传染病第一天只有一个患者,前五天为潜伏期,不发作也不会传染人 第6天开始发作,从发作到治愈需要5天时间,期间每天传染3个人 求第N天共有多少患者
- std::limits
- ZOJ 1078 Palindrom Numbers
- JQuery Method小结
- 再写协处理
- Js获取当前日期时间及其它操作
- 3.腾讯微博Android客户端开发——算法、编码、辅助方法编写
- Android Menu
- 用引用返回值
- 打印机突然出现spoolsv.exe应用程序错误,内存不能written
- 使用 runcluvfy 校验Oracle RAC安装环境