码迷,mamicode.com
首页 > 其他好文 > 详细

小案例

时间:2017-02-19 20:14:48      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:out   system   color   void   div   string   demo   数字   sys   

  • 2003年,一个青年说:“我的生日过了,我现在的年龄正好是我出生年份的四个数字之和.” 这个青年那年出生的?
     1 package com.baidu.demo;
     2 
     3 public class Demo01 {
     4     public static void main(String[] args) {
     5         for (int i = 0; i < 2015; i++) {
     6             int b = i / 1000;
     7             int c = (i - b * 1000) / 100;
     8             int d = (i - b * 1000 - c * 100) / 10;
     9             int e = (i - b * 1000 - c * 100 - d * 10);
    10             if (2015 - i == b + c + d + e) {
    11                 System.out.println(i);
    12             }
    13         }
    14     }
    15 }

    答案是1993和2011

小案例

标签:out   system   color   void   div   string   demo   数字   sys   

原文地址:http://www.cnblogs.com/pangabc/p/6416750.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!