zoukankan      html  css  js  c++  java
  • [C puzzle book] Programming styles

    /* Programming Style 1: Choose the Right Condition
     *Improve the following program fragments through reorganization
     */
    
    while(A) {
        if(B) continue;
        C;
    }
    
    do {
        if(!A) continue;
        else B;
        C;
       } while(A);
    
    if(A)
        if(B)
            if(C) D;
            else;
        else;
    else;
        if(B)
            if(C) E;
            else F;
        else;
    
    
    while((c=getchar())!='\n') {
        if(c==' ') continue;
        if(c=='\t') continue;
        if(c<'0') return(OTHER);
        if(c<='9') return(DIGIT);
        if(c<'a') return(ALPHA);
        return (OTHER
    /*Programming Style 2: Choose the Right Construct
     *Improve the following program fragments through reorganization
     */
    
    done=1=0;
    while (i<MAXI && !done) {
        if((x/=2)>1) {
            i++;
            continue; }
        done++;
    }
    
    
    { 
        if(A) {B; return;}
        if(C) {D; return;}
        if(E) {F; return;}
        G; return;
    }
    
    plusflg=zeroflg=negflg=0;
    if(a>0) ++plusflg;
    if(a==0) ++zeroflg;
    else if(!plusflg) ++negflg;
  • 相关阅读:
    登录认证,全选,反选
    jQuery基础知识
    jQuery
    js练习
    BOM DOM
    mysql视图
    用CrwalSpider爬取boss直聘
    设置piplines.py数据管道
    在middlewares.py文件里添加代理ip
    爬取豆瓣电影
  • 原文地址:https://www.cnblogs.com/abacuspix/p/2630089.html
Copyright © 2011-2022 走看看