基础练习 特殊回文数
来源:互联网 发布:手机淘宝店铺怎么登录 编辑:程序博客网 时间:2024/05/01 02:53
问题描述
123321是一个非常特殊的数,它从左边读和从右边读是一样的。
输入一个正整数n, 编程求所有这样的五位和六位十进制数,满足各位数字之和等于n 。
输入一个正整数n, 编程求所有这样的五位和六位十进制数,满足各位数字之和等于n 。
输入格式
输入一行,包含一个正整数n。
输出格式
按从小到大的顺序输出满足条件的整数,每个整数占一行。
样例输入
52
样例输出
899998
989989
998899
989989
998899
数据规模和约定
1<=n<=54。
import java.util.Scanner;public class Main {public static void main(String[]args){Scanner sc=new Scanner(System.in);int n=sc.nextInt();for(int i=10000;i<=999999;i++){if(i<=99999){int a,b,c,d,e,temp;temp=i;a=temp%10;b=temp/10%10;c=temp/100%10;d=temp/1000%10;e=temp/10000;if(a==e&&b==d&&a+b+c+d+e==n){System.out.println(i);}}else{int a,b,c,d,e,f,temp;temp=i;a=temp%10; b=temp/10%10; c=temp/100%10; d=temp/1000%10; e=temp/10000%10; f=temp/100000; if(a==f&&b==e&&c==d&&a+b+c+d+e+f==n) { System.out.println(i); }}}}}
0 0
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- 基础练习 特殊回文数
- php成员变量获取速度排序时怎么样的?
- 关于HTTPS证书的理解
- 读取FTP文本并入库
- 查询oracle刚刚删除的数据,有时间限制
- Centos 配置mailx使用外部smtp发送邮件
- 基础练习 特殊回文数
- Eclipse中运行Maven打包编译时出现:Perhaps you are running on a JRE rather than a JDK?
- BloomFilter算法概述
- 综合素质评价系统-北上广深必须上的教育项目
- c语言fopen函数
- oracle-the password has expired
- excel2007保存时候比较卡的解决方法
- kafka入门:简介、使用场景、设计原理、主要配置及集群搭建(转)
- JSON.NET VS BinaryFormatter 性能