John逝世与1945年8月31日,他出生的年份刚好是他在世时某个年纪的平方,问John哪年出生的?
    要求写出推理过程!

解决方案 »

  1.   

    #include <iostream.h>void main()
    {
    int a,b;      //假设他是19ab年出生的; 0 <= a <= 4;0 <= b <= 9;
    int c,d;      //假设他是18cd年出生的; 0 <= c <= 9;0 <= d <= 9;
    int k;    //k是在世年龄的岁数  k <= 45-(10*a + b);
    for(a = 0;a <= 4;a++)    //在1900年出生之后的算法
    {
    for(b = 0;b <= 9;b++)
    {
    for(k = 0;k <= 45-(10*a + b);k++)
    {
    if(k*k == 1900 + 10*a + b)
    cout<<"出生于19"<<a<<b<<"年"<<endl;;
    }
    }
        }
    for(c = 0;c <= 4;c++)      //在1900年出生之前的算法
    {
    for(d = 0;d <= 9;d++)
    {
    for(k = 0;k <= 145 - (10*c + d);k++)
    {
    if(k*k == 1800 + 10*c + d)
    cout<<"出生于18"<<c<<d<<"年"<<endl;
    }
    }
        }
    }//输出为:出生于1849年  岁数就在43的时候为平方本人也是菜鸟级人物,在学习过程中,请多多指教~~~~
      

  2.   


                    int y;
    for(int i=0;i<100;i++)
    {
    if(Math.pow(i,2)<1945&&Math.pow(i,2)>1845)
    {
    y = (int)Math.pow(i,2);
    System.out.println(y);
    }
    }结果是1849 1936 我想两个数都对   要么比较长寿 要么英年早逝
      

  3.   


    int y, oldy; for (int i = 0; i < 100; i++) {
    if (Math.pow(i, 2) < 1945 && Math.pow(i, 2) > 1845) {
    y = (int) Math.pow(i, 2); oldy = 1945 - y; if (oldy > i) { System.out.println(y);
    }
    }
    }
      

  4.   

    呵呵:
    1.另出生年份为x
    2.另在世某年纪为a
    列出不等式如下:
    0 < a <= 1945 - x ;
    a * a = x;===>求解不等式 1945 - a^2 - a >= 0;
    得结果 a <= 43.6;
    1849 = 43 * 43;
    ?? = 42 * 42;
    so  john 's birth is 1849 .
      

  5.   

      John逝世与1945年8月31日,他出生的年份刚好是他在世时某个年纪的平方,问John哪年出生的? 一楼的正解,佩服二楼的,写程序我写不出来凑个热闹。首先,第一个条件:JOHN的出生年份是某个整数的平方sqrt1945=44.1,所以JOHN的出生年份可能是以下的数值44的平方=1936
    43的平方=1849
    42的平方=1746
    ……
    1的平方=1第二个条件:这个整数是JOHN在世时的某个年龄1936 在世时间9年 在世时不可能到44岁
    1849 在世时间96年 在世时可以到43岁
    1746 在世时间199年
    依次推,按常理算,JOHN生于1894年,在世96年
    不按常理算,JOHN可能生于1746,1681,1600,1521,1444……
      

  6.   

    class Seek {                                            
      private int year;               //year表示出生年岁,age表示在世的某一年纪
      private int age;

      public void seek () {
         for (year = 1945; year>=0 && year <= 1945; year-)                 
    {                                             
           for (age = 0;age >= 0 && age <= 1945-year; age++){
          if (year == age * age){
            System.out.println ("出生年岁为=" + year);
    System.out.println ("符合该条件的当时年纪为=" + age);
    }
    }
    }
    }
    }
    public class SeekAge {
    public static void main (String args[]) {
    Seek s1 = new Seek();
    s1.seek();
    }