zoukankan      html  css  js  c++  java
  • 面向对象编程增加间接层对程序的扩展

    一下通过代码做出解释:

    View Code
     1 #import <Foundation/Foundation.h>
     2 int main(int argc, const char * argv[])
     3 {
     4     @autoreleasepool
     5     {
     6         NSLog(@"The numbers forme 1 to 5");
     7         for(int i = 1; i <= 5; i++)
     8         {
     9              NSLog(@"%d\n", i);
    10         }
    11     }
    12     return 0;
    13 }
    View Code
     1 #import <Foundation/Foundation.h>
     2 int main(int argc, const char * argv[])
     3 {
     4     @autoreleasepool
     5     {
     6         int count = 5;
     7         NSLog(@"The numbers forme 1 to %d", count);
     8         for(int i = 1; i <= count; i++)
     9         {
    10              NSLog(@"%d\n", i);
    11         }
    12     }
    13     return 0;
    14 }
    View Code
     1 #import <Foundation/Foundation.h>
     2 int main(int argc, const char * argv[])
     3 {
     4     @autoreleasepool
     5     {
     6         int fist = 1, count = 5;
     7         NSLog(@"The numbers forme %d to %d", fist, count);
     8         for(int i = fist; i <= count; i++)
     9         {
    10              NSLog(@"%d\n", i);
    11         }
    12     }
    13     return 0;
    14 }
    View Code
     1 #import <Foundation/Foundation.h>
     2 int main(int argc, const char * argv[])
     3 {
     4     @autoreleasepool
     5     {
     6         int fist, count;
     7         scanf("%d %d", &fist, &count);
     8         NSLog(@"The numbers forme %d to %d", fist, count);
     9         for(int i = fist; i <= count; i++)
    10         {
    11              NSLog(@"%d\n", i);
    12         }
    13     }
    14     return 0;
    15 }

    请观察以上代码,发现是怎么一步一步的对程序扩展的,相信你就的增加一个间接层就有所了解了。

  • 相关阅读:
    题解——草莓(树上切割)
    题解——碰杯
    SCOI2019凉凉记
    题解rotinv
    矩阵快速幂
    质数及线性筛
    题解[ZJOI2007]矩阵游戏
    【实验舱国庆营模拟】Day3 A.code
    【实验舱国庆营模拟】Day2 A.divide
    【纪中集训2019.08.25】【JZOJ6371】树
  • 原文地址:https://www.cnblogs.com/chenxiangxi/p/2456883.html
Copyright © 2011-2022 走看看