十种代码作派

十种代码风格

 

以下十种代码风格,你属于那种:

1.  Ansi/Allman/Bsd风格(格式缩进从下一行开始括号) 
int Foo(bool isBar) 
{ 
    if (isBar) 
    { 
        bar(); 
        return 1; 
    } 
    else 
        return 0; 
}  

2.  Java风格(格式缩进直接紧接后面括号) 
int Foo(bool isBar) { 
    if (isBar) { 
        bar(); 
        return 1; 
    } else 
        return 0; 
} 

3.  Kernighan_Ritchie风格(格式缩进使用Linux 方式括号) 
int Foo(bool isBar)  
{ 
    if (isBar) { 
        bar(); 
        return 1; 
    } else 
        return 0; 
} 

4.  Stroustrup风格(格式缩进使用stroustrup 方式括号,缩进使用5 个空格) 
int Foo(bool isBar)  
{ 
     if (isBar) { 
          bar(); 
          return 1; 
     } else 
          return 0; 
} 

5.  Whitesmith风格(格式缩进使用下一行且缩进的括号) 
int Foo(bool isBar)  
    { 
    if (isBar) 
        { 
        bar(); 
        return 1; 
        } 
    else 
        return 0; 
    } 
 
6.  Banner 风格(格式缩进使用直接紧接和缩进的括号) 
int Foo(bool isBar) { 
    if (isBar) { 
        bar(); 
        return 1; 
        } 
    else 
        return 0; 
    } 

7.  GNU 风格(格式缩进使用下一行括号,语句块括号缩进两个空格) 
int Foo(bool isBar) 
{ 
  if (isBar) 
    { 
      bar(); 
      return 1; 
    } 
  else 
    return 0; 
} 

8.  Linux 风格(格式缩进使用  Linux 方式括号,语句块里面缩进8 个空格) 
int Foo(bool isBar) 
{ 
        if (isFoo) { 
                bar(); 
                return 1; 
        } else 
                return 0; 
} 

9.  Horstmann风格(格式缩进使用horstman方式,括号紧接语句块) 
int Foo(bool isBar) 
{  if (isBar) 
   {  bar(); 
      return 1; 
   } else 
      return 0; 
} 
 
10.  1tbs/otbs风格(格式缩进使用Linux 方式括号,自动补全单行语句块括号) 
int Foo(bool isBar) 
{ 
    if (isFoo) { 
        bar(); 
        return 1; 
    } else { 
        return 0; 
    } 
} 

 

1 楼 yeshaoting 2010-12-26  
我是第一种.十种代码作派