zoukankan      html  css  js  c++  java
  • C语言 · 年龄巧合

    标题:年龄巧合

        小明和他的表弟一起去看电影,有人问他们的年龄。小明说:今年是我们的幸运年啊。我出生年份的四位数字加起来刚好是我的年龄。表弟的也是如此。已知今年是2014年,并且,小明说的年龄指的是周岁。

        请推断并填写出小明的出生年份。

        这是一个4位整数,请通过浏览器提交答案,不要填写任何多余的内容(比如,他表弟的出生年份,或是他们的年龄等等)。

     1 #include<stdio.h>
     2 #include<math.h>
     3 int main(){
     4     int y;
     5     for(y=1930;y<2014;y++){
     6         int a=y/1000%10;
     7         int b=y/100%10;
     8         int c=y/10%10;
     9         int d=y%10;
    10         if(a+b+c+d==2014-y){
    11             printf("%d
    ",y);
    12         }
    13     }
    14     return 0;
    15 }
  • 相关阅读:
    前端基础之BOM和DOM
    前端基础之JavaScript
    前端基础之CSS
    Black And White HDU
    Robot Motion HDU
    A Knight's Journey POJ
    Find a way HDU
    排序 HDU
    Dungeon Master POJ
    Network Saboteur POJ
  • 原文地址:https://www.cnblogs.com/panweiwei/p/6682904.html
Copyright © 2011-2022 走看看