Docstoc

建立靜態資料成員

Document Sample
建立靜態資料成員 Powered By Docstoc
					第三次小考
n   #include<iostream>
n   using namespace std;

n   int aaa(int *ib,int a1,int a2)
n   {
n         int u,v;
n         int m=(a1+a2)/2;
n         if(a1==a2)return ib[a1];
n         u=aaa(ib,a1,m);
n         cout<<"u="<<u<<"\n";
n         v=aaa(ib,m+1,a2);
n         cout<<"v="<<v<<"\n";
n         if(u>v)return u;else return v;
n   }

n   int main()
n   {
n        int ia[10]={0,2,3,6,8,6,12,28,16,11};
n        cout<<aaa(ia,0,9)<<"\n";
n        return 0;
n   }
aaa(ib,0,9)
n   int aaa(int *ib,int a1,int a2)   傳入參數 a1=0,a2=9

n   {
n       int u,v;                   m=(0+9)/2 ……
                              因為m屬於int,所以m等於整數部份
n       int m=(a1+a2)/2;               m=4

n       if(a1==a2)return ib[a1]; a1=0,a2=9 à沒有return
n       u=aaa(ib,a1,m);                傳入aaa(ib,0,4)

n       cout<<"u="<<u<<"\n";
n       v=aaa(ib,m+1,a2);
n       cout<<"v="<<v<<"\n";
n       if(u>v)return u;else return v;
n   }
        aaa(ib,0,9)



aaa(ib,0,4)
n   int aaa(int *ib,int a1,int a2)   傳入參數 a1=0,a2=4

n   {
n       int u,v;                   m=(0+4)/2 ……
                              因為m屬於int,所以m等於整數部份
n       int m=(a1+a2)/2;               m=2

n       if(a1==a2)return ib[a1]; a1=0,a2=4à沒有return
n       u=aaa(ib,a1,m);                傳入aaa(ib,0,2)

n       cout<<"u="<<u<<"\n";
n       v=aaa(ib,m+1,a2);
n       cout<<"v="<<v<<"\n";
n       if(u>v)return u;else return v;
n   }
                aaa(ib,0,9)


        aaa(ib,0,4)


aaa(ib,0,2)
n   int aaa(int *ib,int a1,int a2)   傳入參數 a1=0,a2=2

n   {
n       int u,v;                   m=(0+2)/2 ……
                              因為m屬於int,所以m等於整數部份
n       int m=(a1+a2)/2;               m=1

n       if(a1==a2)return ib[a1]; a1=0,a2=2à沒有return
n       u=aaa(ib,a1,m);                傳入aaa(ib,0,1)

n       cout<<"u="<<u<<"\n";
n       v=aaa(ib,m+1,a2);
n       cout<<"v="<<v<<"\n";
n       if(u>v)return u;else return v;
n   }
                        aaa(ib,0,9)


                aaa(ib,0,4)


        aaa(ib,0,2)


aaa(ib,0,1)
n   int aaa(int *ib,int a1,int a2)   傳入參數 a1=0,a2=1

n   {
n       int u,v;                   m=(0+1)/2 ……
                              因為m屬於int,所以m等於整數部份
n       int m=(a1+a2)/2;               m=0

n       if(a1==a2)return ib[a1]; a1=0,a2=1à沒有return
n       u=aaa(ib,a1,m);                傳入aaa(ib,0,0)

n       cout<<"u="<<u<<"\n";
n       v=aaa(ib,m+1,a2);
n       cout<<"v="<<v<<"\n";
n       if(u>v)return u;else return v;
n   }
                                aaa(ib,0,9)


                        aaa(ib,0,4)


                aaa(ib,0,2)


        aaa(ib,0,1)


aaa(ib,0,0)
n   int aaa(int *ib,int a1,int a2)   傳入參數 a1=0,a2=0

n   {
n       int u,v;                   m=(0+2)/2 ……
                              因為m屬於int,所以m等於整數部份
n       int m=(a1+a2)/2;               m=1

n       if(a1==a2)return ib[a1]; a1=0,a2=0àreturn ib[0]
n       u=aaa(ib,a1,m);
n       cout<<"u="<<u<<"\n";
n       v=aaa(ib,m+1,a2);
n       cout<<"v="<<v<<"\n";
n       if(u>v)return u;else return v;
n   }
                                               aaa(ib,0,9)


                                        aaa(ib,0,4)

                                 aaa(ib,0,2)

                          aaa(ib,0,1)

                  aaa(ib,0,0)
u=aaa(ib,0,0)=0
                  return ib[0]
                    (ib[0]=0)
n   int aaa(int *ib,int a1,int a2)   傳入參數 a1=0,a2=1

n   {
n       int u,v;                   m=(0+1)/2 ……
                              因為m屬於int,所以m等於整數部份
n       int m=(a1+a2)/2;               m=0

n       if(a1==a2)return ib[a1]; a1=0,a2=1à沒有return
                                   aaa(ib,0,0) return ib[0]
n       u=aaa(ib,a1,m);             所以 u=ib[0] (u=0)
n       cout<<"u="<<u<<"\n";                 u=0

n       v=aaa(ib,m+1,a2);              傳入aaa(ib,1,1)

n       cout<<"v="<<v<<"\n";
n       if(u>v)return u;else return v;
n   }
                                         aaa(ib,0,9)


                                 aaa(ib,0,4)


                         aaa(ib,0,2)


         aaa(ib,0,1)

aaa(ib,0,0)      aaa(ib,1,1)
   u=0
return ib[0]
  (ib[0]=0)
n   int aaa(int *ib,int a1,int a2)   傳入參數 a1=1,a2=1

n   {
n       int u,v;                   m=(1+1)/2 ……
                              因為m屬於int,所以m等於整數部份
n       int m=(a1+a2)/2;               m=1

n       if(a1==a2)return ib[a1]; a1=a2=1àreturn ib[1]
n       u=aaa(ib,a1,m);
n       cout<<"u="<<u<<"\n";
n       v=aaa(ib,m+1,a2);
n       cout<<"v="<<v<<"\n";
n       if(u>v)return u;else return v;
n   }
                                              aaa(ib,0,9)


                                  aaa(ib,0,4)


                          aaa(ib,0,2)


         aaa(ib,0,1)

aaa(ib,0,0)      aaa(ib,1,1)
   u=0              v=2
                                v=aaa(ib,1,1)=2

return ib[0]     return ib[1]
  (ib[0]=0)        (ib[1]=2)
n   int aaa(int *ib,int a1,int a2)   傳入參數 a1=0,a2=1

n   {
n       int u,v;                   m=(0+1)/2 ……
                              因為m屬於int,所以m等於整數部份
n       int m=(a1+a2)/2;               m=0

n       if(a1==a2)return ib[a1]; a1=0,a2=1à沒有return
n       u=aaa(ib,a1,m);                傳入aaa(ib,0,0)

n       cout<<"u="<<u<<"\n";                u=0

n       v=aaa(ib,m+1,a2);              v = aaa(ib,1,1)
n       cout<<"v="<<v<<"\n";                v=2
n       if(u>v)return u;else return v;         u=0 ,v = 2
                                           v>u return v (v=2)
n   }
                                                 aaa(ib,0,9)


                                         aaa(ib,0,4)


                                  aaa(ib,0,2)

                 aaa(ib,0,1)
     v>u            u=2
return v (v=2)

    aaa(ib,0,0)          aaa(ib,1,1)
       u=0                  v=2

   return ib[0]          return ib[1]
     (ib[0]=0)             (ib[1]=2)
n   int aaa(int *ib,int a1,int a2)   傳入參數 a1=0,a2=2

n   {
n       int u,v;                   m=(0+2)/2 ……
                              因為m屬於int,所以m等於整數部份
n       int m=(a1+a2)/2;               m=1

n       if(a1==a2)return ib[a1]; a1=0,a2=2à沒有return
n       u=aaa(ib,a1,m);               u=aaa(ib,0,1)=2

n       cout<<"u="<<u<<"\n";                u=2

n       v=aaa(ib,m+1,a2);              傳入aaa(ib,2,2)

n       cout<<"v="<<v<<"\n";
n       if(u>v)return u;else return v;
n   }
                                              aaa(ib,0,9)


                                       aaa(ib,0,4)


                         aaa(ib,0,2)

        aaa(ib,0,1)
                                aaa(ib,2,2)
           u=2

aaa(ib,0,0)     aaa(ib,1,1)
   u=0             v=2

return ib[0]    return ib[1]
  (ib[0]=0)       (ib[1]=2)
n   int aaa(int *ib,int a1,int a2)   傳入參數 a1=2,a2=2

n   {
n       int u,v;                   m=(2+2)/2 ……
                              因為m屬於int,所以m等於整數部份
n       int m=(a1+a2)/2;               m=2

n       if(a1==a2)return ib[a1]; a1=a2=2àreturn ib[2] (ib[2]=3)
n       u=aaa(ib,a1,m);
n       cout<<"u="<<u<<"\n";
n       v=aaa(ib,m+1,a2);
n       cout<<"v="<<v<<"\n";
n       if(u>v)return u;else return v;
n   }
                                                aaa(ib,0,9)


                                        aaa(ib,0,4)


                         aaa(ib,0,2)

        aaa(ib,0,1)              aaa(ib,2,2)
           u=2                      v=3
                                               v=aaa(ib,2,2)=3

aaa(ib,0,0)     aaa(ib,1,1)     return ib[2]
   u=0             v=2            (ib[2]=3)

return ib[0]    return ib[1]
  (ib[0]=0)       (ib[1]=2)
n   int aaa(int *ib,int a1,int a2)   傳入參數 a1=0,a2=2

n   {
n       int u,v;                   m=(0+2)/2 ……
                              因為m屬於int,所以m等於整數部份
n       int m=(a1+a2)/2;               m=1

n       if(a1==a2)return ib[a1]; a1=0,a2=2à沒有return
n       u=aaa(ib,a1,m);               u=aaa(ib,0,1)=2

n       cout<<"u="<<u<<"\n";                u=2

n       v=aaa(ib,m+1,a2);              傳入aaa(ib,2,2)

n       cout<<"v="<<v<<"\n";                v=3

n       if(u>v)return u;else return v;        u=2 ,v = 3
                                          v>u return v (v=3)
n   }
                                                  aaa(ib,0,9)


                                           aaa(ib,0,4)

                            aaa(ib,0,2)
                v>u            u=3
           return v (v=3)

        aaa(ib,0,1)                 aaa(ib,2,2)
           u=2                         v=3

aaa(ib,0,0)       aaa(ib,1,1)      return ib[2]
   u=0               v=2             (ib[2]=3)

return ib[0]      return ib[1]
  (ib[0]=0)         (ib[1]=2)
n   int aaa(int *ib,int a1,int a2)   傳入參數 a1=0,a2=4

n   {
n       int u,v;                   m=(0+4)/2 ……
                              因為m屬於int,所以m等於整數部份
n       int m=(a1+a2)/2;               m=2

n       if(a1==a2)return ib[a1]; a1=0,a2=4à沒有return
n       u=aaa(ib,a1,m);                傳入aaa(ib,0,2)

n       cout<<"u="<<u<<"\n";           aaa(ib,0,2) = 3
                                            u=3
n       v=aaa(ib,m+1,a2);             傳入 aaa(ib,3,4)
n       cout<<"v="<<v<<"\n";
n       if(u>v)return u;else return v;
n   }
                                                         aaa(ib,0,9)



                                           aaa(ib,0,4)


                           aaa(ib,0,2)
                                                  aaa(ib,3,4)
               v>u            u=3
          return v (v=3)

         aaa(ib,0,1)               aaa(ib,2,2)
            u=2                       v=3

aaa(ib,0,0)       aaa(ib,1,1)     return ib[2]
   u=0               v=2            (ib[2]=3)

return ib[0]     return ib[1]
  (ib[0]=0)        (ib[1]=2)
加油~~!!
繼續做下去一定會是
以下結果
                                                 aaa(ib,0,9)
                                                    28


                                          aaa(ib,0,4)    aaa(ib.5,9)
                                             u=8           v=28


                          aaa(ib,0,2)                     aaa(ib,3,4)
                             u=3                             v=8

         aaa(ib,0,1)
                                  aaa(ib,2,2)    aaa(ib,3,3)      aaa(ib,4,4)
            u=2
                                     v=3            u=6              v=8


aaa(ib,0,0)      aaa(ib,1,1)
                                  return ib[2]   return ib[3]     return ib[4]
   u=0              v=2


return ib[0]     return ib[1]
                              aaa(ib,0,9)
                                  28


aaa(ib,0,4)                                                aaa(ib.5,9)
   u=8                                                       v=28


                       aaa(ib,5,7)                                        aaa{ib,8,9)
                         u=28                                               v=16


        aaa(ib,5,6)                         aaa(ib,6,7)           aaa(ib,8,8)    Aaa(ib,9,9)
          u=12                                v=28                  u=16           v=11


aaa(ib,5,5)    aaa(ib,6,6)       aaa(ib,6,6)       aaa(ib,7,7)
                                                                  return ib[8]   return ib[9]
   u=6           v=12              u=12              v=28


               return ib[6]
return ib[5]                     return ib[6]      return ib[7]

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:6
posted:6/13/2013
language:Romanian
pages:30