佳礼资讯网

 找回密码
 注册

ADVERTISEMENT

查看: 1239|回复: 18

C++求助!急!!!

[复制链接]
发表于 27-3-2013 03:37 PM | 显示全部楼层 |阅读模式
我有一个assignment是用C++ 来做一个auto billing system
“press any key for next payment" / " press enter for next payment" 的 code是什么?
回复

使用道具 举报


ADVERTISEMENT

发表于 27-3-2013 05:12 PM | 显示全部楼层
Console mode: getch();

Windows mode: OnKeyPressed()/OnKeyDown();

自己去看说明书。

回复

使用道具 举报

 楼主| 发表于 27-3-2013 05:40 PM | 显示全部楼层
geekman 发表于 27-3-2013 05:12 PM
Console mode: getch();

Windows mode: OnKeyPressed()/OnKeyDown();

#include<iostream>
using namespace std;
int main()
{
        double number=0;
        double total=0;
        double member;
        char yn;
        do{
        cout<<"BODY TREATMENT"<<endl;
        cout<<"=============================================================="<<"\n";
        cout<<"TREATMENTS                            PRICES"<<"\n\n";
        cout<<"1. HERBAL BATH                            RM 200"<<"\n\n";
        cout<<"2. TRADITIONAL MASSAGE        RM 110(60 Minutes)"<<"\n\n";
        cout<<"3. TRADITIONAL MASSAGE        RM 150(90 Minutes)"<<"\n\n";
        cout<<"4. TRADITIONAL MASSAGE        RM 190(120 Minutes)"<<"\n\n";
        cout<<"5. TRADITIONAL AROTHERAPY MASSAGE      RM 130(60 Minutes)"<<"\n\n";
        cout<<"6. TRADITIONAL AROTHERAPY MASSAGE      RM 170(90 Minutes)"<<"\n\n";
        cout<<"7. TRADITIONAL AROTHERAPY MASSAGE      RM 210(120 Minutes)"<<"\n\n";
        cout<<"==============================================================="<<"\n\n\n";
        cout<<"Hair Treatment"<<endl;
        cout<<"TREATMENT                    PRICES"<<"\n\n";
        cout<<"8. HAIR CUT                     RM 35"<<"\n\n";
        cout<<"9. SHAMPOO & BLOW               RM 28(Long)"<<"\n\n";
        cout<<"10. SHAMPOO & BLOW                                RM 20(SHort)"<<"\n\n";
        cout<<"11. COLORING                                                RM 110(Long)"<<"\n\n";
        cout<<"12. COLORING                                                RM 95(Short)"<<"\n\n";
        cout<<"13. HAIR SPA                                                RM 220(Long)"<<"\n";
        cout<<"*(Wash,hair mask, wash scalp massage with cream,steam shoulder scrub and massage, hair tonic & blow dry)"<<"\n\n";
        cout<<"14. HAIR SPA                                                RM 180(Short)"<<"\n";
        cout<<"*(Wash,hair mask, wash scalp massage with cream,steam shoulder scrub and massage, hair tonic & blow dry)"<<"\n\n";
        cout<<"============================================================"<<"\n\n\n";
        cout<<"PLEASE ENTER BODY/HAIR STREATMENT NUMBER:"<<"\n";
        cin>>number;
        cout<<"TOTAL:"<<number<<"\n\n";
       
        if(number==1)
                total=total+200;
        else
        if(number==2)
                total=total+110;
        else
        if(number==3)
                total=total+150;
        else
        if(number==4)
                total=total+190;
        else
        if(number==5)
                total=total+130;
        else
        if(number==6)
                total=total+170;
        else
        if(number==7)
                total=total+210;
        else
        if(number==8)
                total=total+35;
        else
        if(number==9)
                total=total+28;
        else
        if(number==10)
                total=total+20;
        else
        if(number==11)
                total=total+110;
        else
        if(number==12)
                total=total+95;
        else
        if(number==13)
                total=total+220;
        else
        if(number==14)
                total=total+180;
        else

        cout<<"ERROR.PLEASE TRY AGAIN!\n\n\n";
        {
        char yesNO;
        cout<<"MEMBER: (y/n)"<<"\n";
        cin>>yesNO;
        if(yesNO=='y')
        {
                total=total-(total*0.25);
        }
       
        cout<<"TOTAL AMOUNT:                           RM "<<total<<"\n\n\n";

        system("pause");
        return 0;
        }
        }
}



c:\users\user\documents\visual studio 2010\projects\assignment\assignment\auto billing system.cpp(96): error C2059: syntax error : '}'

帮我看看




回复

使用道具 举报

发表于 27-3-2013 06:04 PM | 显示全部楼层
auto billing system.cpp(96): error C2059: syntax error : '}'

回复

使用道具 举报

 楼主| 发表于 27-3-2013 06:06 PM | 显示全部楼层
megablue 发表于 27-3-2013 06:04 PM
auto billing system.cpp(96): error C2059: syntax error : '}'

帮我改下~~~~
回复

使用道具 举报

发表于 28-3-2013 12:23 AM | 显示全部楼层
苹果菜 发表于 27-3-2013 06:06 PM
帮我改下~~~~

我没看错吧...
回复

使用道具 举报

Follow Us
发表于 28-3-2013 01:04 AM | 显示全部楼层
'}'

本帖最后由 e_mc_square 于 28-3-2013 01:09 AM 编辑

回复

使用道具 举报

发表于 28-3-2013 11:30 AM | 显示全部楼层
苹果菜 发表于 27-3-2013 05:40 PM
#include
using namespace std;
int main()

请学习使用正确的Code Formatting和Indentation,别学Microsoft那个蠢蛋工程师的坏习惯,把open bracket和close baracket放在不同的indentation level,这是很愚蠢的操蛋行为!
  1. for(int i=0; i<max; i++){
  2. ...
  3. }
复制代码
这是很愚蠢的做法!这会让你很容易的忽略bracket pairing。

正确做法:
  1. for(int 1=0; i<max; i++)
  2. {
  3.     ...
  4. }
复制代码
你就能够轻易地判断各个Barcket的开和关。

你犯的错误就在:
  1. do{
  2. }
复制代码
什么错误?自己想。

至于
  1. if(number==1)
  2.                 total=total+200;
  3.         else
  4.         if(number==2)
  5.                 total=total+110;
  6.         else
  7.         if(number==3)
  8.                 total=total+150;
  9.         else
  10.         if(number==4)
  11.                 total=total+190;
  12.         else
  13.         if(number==5)
  14.                 total=total+130;
  15.         else
  16.         if(number==6)
  17.                 total=total+170;
  18.         else
  19.         if(number==7)
  20.                 total=total+210;
  21.         else
  22.         if(number==8)
  23.                 total=total+35;
  24.         else
  25.         if(number==9)
  26.                 total=total+28;
  27.         else
  28.         if(number==10)
  29.                 total=total+20;
  30.         else
  31.         if(number==11)
  32.                 total=total+110;
  33.         else
  34.         if(number==12)
  35.                 total=total+95;
  36.         else
  37.         if(number==13)
  38.                 total=total+220;
  39.         else
  40.         if(number==14)
  41.                 total=total+180;
  42.         else

  43.         cout<<"ERROR.PLEASE TRY AGAIN!\n\n\n";
复制代码
更是十分猛烈的操蛋行为,为什么不用switch()(当然,switch也不是最佳选择。至于最佳选择是什么?这是秘密,商业秘密 )?还有,把else if分成两行?if之下的statement没有indentation?还有最后一个else是什么意思?

根据你的写法,最后一个else只会执行
  1. cout<<"ERROR.PLEASE TRY AGAIN!\n\n\n";
复制代码
这行。至于
  1.         {

  2.             char yesNO;

  3.             cout<<"MEMBER: (y/n)"<<"\n";

  4.             cin>>yesNO;

  5.             if(yesNO=='y')

  6.             {

  7.                 total=total-(total*0.25);

  8.             }

  9.         

  10.             cout<<"TOTAL AMOUNT:                           RM "<<total<<"\n\n\n";



  11.             system("pause");

  12.             return 0;

  13.         }
复制代码
root-less bracket?

根据你的代码,你这个程式的运作方式是:
1)打印出服务/价格列表
2)读取用户输入(number)
3)根据number,增加total(total = total + price)
4)询问是否会员。
5)根据输入,打印出总额( total=total-(total*0.25);)
6)结束程式(你的程式并不会loop,你犯了两个错误,自己想。)

如果顾客使用了5项服务,你得开5次单。。。

恭喜你,你这个学期的C++ Programming 成绩是 F-Distinction。是的,Fail with Distinction。网络用语:Epic Fail。
本帖最后由 geekman 于 28-3-2013 11:53 AM 编辑

评分

参与人数 1人气 +5 收起 理由
cokedreamer + 5 我很赞同

查看全部评分

回复

使用道具 举报


ADVERTISEMENT

发表于 28-3-2013 12:34 PM | 显示全部楼层
geekman 发表于 28-3-2013 11:30 AM
请学习使用正确的Code Formatting和Indentation,别学Microsoft那个蠢蛋工程师的坏习惯,把open bracket和 ...

哇 你好认真, lz给人的感觉好像是懒惰做的那种。

上次我才看到有个外国的程序员主张:
  1. for(int i=0; i<max; i++){
  2. ...
  3. }
复制代码
而不是:
  1. for(int 1=0; i<max; i++)
  2. {
  3.     ...
  4. }
复制代码
不过现在的IDE editor都很好的, 很少会再出现忘记bracket的问题。

本帖最后由 fire-fly3 于 28-3-2013 12:35 PM 编辑

评分

参与人数 1人气 +5 收起 理由
cokedreamer + 5 我很赞同

查看全部评分

回复

使用道具 举报

发表于 28-3-2013 12:49 PM | 显示全部楼层
fire-fly3 发表于 28-3-2013 12:34 PM
哇 你好认真, lz给人的感觉好像是懒惰做的那种。

上次我才看到有个外国的程序员主张:而不是 ...

第一种写法并没有任何好处,会让程序员很难判断 bracket pairing(楼主的 Code 就很完美的为大家诠释演绎了这蠢 coding style 的妙处 -  他甚至没注意到他的 do-while loop 只有 do,没有 while。。。),如果程序员必须在没有 IDE 的 code assist 情形下写 code,这种愚蠢的 coding style 绝对会让编程员死得很难看。这蠢方法除了让 code 变得很不整齐外,就只有让你在几GB的记忆体里面节省了两个byte(CR+LF)罢了。除非你的 source code 真的庞大到能够填满16GB 的记忆体 + 近乎无限的 Page File(相信 Windows 9 的 Source Code 都无法做到这样的创举),不然我真的看不出那种死蠢的coding style有任何好处。

可否给个 link 来让我见识一下都到底是哪个脑残的编程员提议这么个极品的主张,以及他的为何要这么做的原因?

回复

使用道具 举报

发表于 28-3-2013 02:41 PM | 显示全部楼层
geekman 发表于 28-3-2013 12:49 PM
第一种写法并没有任何好处,会让程序员很难判断 bracket pairing(楼主的 Code 就很完美的为大家诠释演绎 ...

我已经忘了什么书名, 在某本书里面有提到一点点。

因为java的coding convention是用第一种, 所以我看惯了第一种。 不过好坏很难说, 很主观下的。

刚查了下wiki, 分享下其中一个使用第二种的坏处:


Additionally, the blocking style delineates the actual block of code from the associated control statement itself. Commenting out the control statement, removing the control statement entirely, refactoring, or removing of the block of code is less likely to introduce syntax errors because of dangling or missing brackets.

For example, the following is still syntactically correct:
  1. //while (x == y)
  2. {
  3.     something();
  4.     somethingelse();
  5. }
复制代码
As is this:
  1. //for (int i=0; i < x; i++)
  2. //while (x == y)
  3. if (x == y)
  4. {
  5.     something();
  6.     somethingelse();
  7. }
复制代码
Even like this, with conditional compilation:
  1. char c;
  2. #ifdef HAS_GETCH
  3. while ((c = getch()) != EOF)
  4. #else
  5. while ((c = getchar()) != EOF)
  6. #endif
  7. {
  8.     do_something(c);
  9. }
复制代码
如果是使用第一种indent, compiler就比较可能给error warning (因为bracket也被comment掉了)。 所以上面的说法是认为有error warning 总好过隐藏的logical error。

不过还有其他比较, 我没有去看完了。 懒惰读完。


回复

使用道具 举报

发表于 28-3-2013 03:23 PM | 显示全部楼层
我还是无法认同该书作者的主张,身为一个合格的Programmer,应该很清醒的知道自己在做什么,当comment-out代码的时候,应该自己心里有数自己comment了什么,而不是靠这种让Code变得很不整齐的方式来编码。这只是一个懒惰的编程员的借口。

我个人的主张是代码就必须清晰明了,哪里开,哪里关,哪个开括号对哪个关括号,只要配合正确的indentation,以及一些适当的Spacing对准,自然就一目了然。如果我看到乱糟糟的代码,我完全不会有兴趣去研究它写些什么,更别论要花心思去研究和思考它的内容。

例如楼主的代码,我就是复制到Notepad++,然后重新format过,加入应有的indentation,结果马上就看到问题出在哪里了。

虽然我并不认为我是什么权威性的大神,但是这些简单的编程问题我还是能够帮忙解决的,只是如果发问者不能根据合理的格式把代码排列成清晰易读的格式,那如果我心情比较不好时,基本就会无视这些问题,那发问者就少了一个解决问题的机会了。毕竟我不是每天都有心情去重新 formatting 别人乱糟糟的代码的。

所以,我个人的主张是:你在自己工作/功课方面如何做,我管不着,只要你的同事/导师能够接受就好,不过如果你是来论坛询问的,那我恳请各位,将你的代码格式化成最清晰,最容易阅读的方式呈现上来,好让想帮助你的人少一些麻烦,好吗?

如果楼主的代码是这样的,我想,他不必问别人,自己都应该能够发现问题出在哪儿了:
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     double number = 0; // why use double if what you need is just a short??
  6.     double total  = 0; // you really need double for currency? 32 bit decimal points??
  7.     double member;     // for what? unused variable
  8.     char   yn;         // for what? II unused variable again!

  9.     do
  10.     {
  11.         cout << "BODY TREATMENT" << endl;
  12.         cout << "=========================================================" << "\n";
  13.         cout << "TREATMENTS                          PRICES" << "\n\n";
  14.         cout << "1.  HERBAL BATH                     RM 200" << "\n\n";
  15.         cout << "2.  TRADITIONAL MASSAGE             RM 110( 60 Minutes)" << "\n\n";
  16.         cout << "3.  TRADITIONAL MASSAGE             RM 150( 90 Minutes)" << "\n\n";
  17.         cout << "4.  TRADITIONAL MASSAGE             RM 190(120 Minutes)" << "\n\n";
  18.         cout << "5.  TRADITIONAL AROTHERAPY MASSAGE  RM 130( 60 Minutes)" << "\n\n";
  19.         cout << "6.  TRADITIONAL AROTHERAPY MASSAGE  RM 170( 90 Minutes)" << "\n\n";
  20.         cout << "7.  TRADITIONAL AROTHERAPY MASSAGE  RM 210(120 Minutes)" << "\n\n";
  21.         cout << "=========================================================" << "\n\n\n";
  22.         cout << "Hair Treatment" << endl;
  23.         cout << "TREATMENTS                          PRICES" << "\n\n";
  24.         cout << "8.  HAIR CUT                        RM  35" << "\n\n";
  25.         cout << "9.  SHAMPOO & BLOW                  RM  28(Long)"  << "\n\n";
  26.         cout << "10. SHAMPOO & BLOW                  RM  20(SHort)" << "\n\n";
  27.         cout << "11. COLORING                        RM 110(Long)"  << "\n\n";
  28.         cout << "12. COLORING                        RM  95(Short)" << "\n\n";
  29.         cout << "13. HAIR SPA                        RM 220(Long)"  << "\n";
  30.         cout << "*(Wash,hair mask, wash scalp massage with cream,"  << "\n";
  31.         cout << "  steam shoulder scrub and massage, hair tonic & blow dry)" << "\n\n";
  32.         cout << "14. HAIR SPA                        RM 180(Short)" << "\n";
  33.         cout << "*(Wash,hair mask, wash scalp massage with cream, " << "\n";
  34.         cout << "  steam shoulder scrub and massage, hair tonic & blow dry)"<<"\n\n";
  35.         cout << "=========================================================" << "\n\n\n";
  36.         cout << "PLEASE ENTER BODY/HAIR TREATMENT NUMBER:" << "\n";
  37.         cin >> number;
  38.         cout << "TOTAL: " <<number << "\n\n";

  39.         if(number == 1)
  40.             total = total + 200;
  41.         else if(number == 2)
  42.             total = total + 110;
  43.         else if(number == 3)
  44.             total = total + 150;
  45.         else if(number == 4)
  46.             total = total + 190;
  47.         else if(number == 5)
  48.             total = total + 130;
  49.         else if(number == 6)
  50.             total = total + 170;
  51.         else if(number == 7)
  52.             total = total + 210;
  53.         else if(number == 8)
  54.             total = total + 35;
  55.         else if(number == 9)
  56.             total = total + 28;
  57.         else if(number == 10)
  58.             total = total + 20;
  59.         else if(number == 11)
  60.             total = total + 110;
  61.         else if(number == 12)
  62.             total = total + 95;
  63.         else if(number == 13)
  64.             total = total + 220;
  65.         else if(number == 14)
  66.             total = total + 180;
  67.         else
  68.             cout << "ERROR. PLEASE TRY AGAIN!\n\n\n";

  69.         {         //why?
  70.         char yesNO;
  71.         cout << "MEMBER: (y/n)" << "\n";
  72.         cin  >> yesNO; // extra space added to align the << and >> operatore,
  73.                        // looks more tidy
  74.         if(yesNO == 'y')
  75.         {
  76.             total = total - (total * 0.25);
  77.         }
  78.         cout << "TOTAL AMOUNT:                           RM " << total << "\n\n\n";

  79.         system("pause");
  80.         return 0; // any use for this 0?? could've return void.
  81.         }         //why??
  82.     } // so now you know this is paired with a do{,
  83.       // wouldn't you be curious why a lonely } appears here?
  84. }
复制代码
本帖最后由 geekman 于 28-3-2013 04:03 PM 编辑

回复

使用道具 举报

发表于 28-3-2013 04:19 PM | 显示全部楼层
嗯。。。实在无法忍受那操蛋的15个if-else。。。

更省事的做法是:

  1. float prices[15] = {0, 200, 110, 150, 190, 139, 170, 210,
  2.                         35,  28,  20, 110,  95, 220, 180};

  3. ...
  4. do
  5. {
  6.     ...
  7.     cin >> number;
  8.     ...
  9.     if(number >= 1 && number <= 14)
  10.         total += prices[number];
  11.     ...
  12. }
复制代码
楼主先把你原本的代码show给你lecturer看,然后在他/她跟心脏病挣扎的时候,再show这段代码,应该能让你得到++分的。

edit: 发现bug,user choice应该是1-14,0不包括在内。。。所以Array加多一个dummy element,跳过 element 0。
本帖最后由 geekman 于 29-3-2013 09:36 AM 编辑

回复

使用道具 举报

发表于 28-3-2013 07:17 PM | 显示全部楼层
coding convention/style, 在大部分情况下其实没有什么对或错的, 只是你的习惯而已, 重要的是保持consistency。
但Indention 就很重要了... 不然改代码的时候真的会读书死你。coding convention/style 的最重要的目的是让代码好看好读,没必要去坚持对错(也没有绝对的错与对)

至于
  1. while(isSunday){
  2.     doSomething();
  3. }
复制代码
  1. while(isSunday)
  2. {
  3.     doSomething();
  4. }
复制代码
各有喜好,而没有对错之分。而且上面的情况还有个例外就是在javascript, 第一个是必要的,第二个虽然可行,但在某些javascript parser/compiler/interpretor 就会出错。

最最最最重要的是当你work as a team 的时候,就必须跟大队,不然写出来的code... 一些用tab来indent, 一些用space来indent...然后space的格数也不一样,这样你的team很难读懂你的code了。 如果你有在open source software贡献过代码就懂了...有些厉害一点contributors/founders的,直接刁你。

还有,以下的纯属我个人习惯,就是把if-else 和if 的 conditional statements (视觉上)简化。
我几乎完全没有用 else 和 switch  statement了。
而且连nested if 也非常少用。
我的目的是增加代码的可读性。

  1. boolean isAWinner = (a > b);
  2. boolean isBWinner = (b > a);
  3. boolean isDraw = (a == b);
  4. boolean isPuzzleSolved = (totalMoves == 0);
  5. boolean isNewTopScore = (myScore >= topScore);
  6. int newTopScore = myScore;

  7. if(isAWinner && !isPuzzleSolved && isNewTopScore){
  8.     doSomething();
  9. }

  10. if(isAWinner && isPuzzleSolved && isNewTopScore){
  11.     doSomething();
  12. }

  13. if(isAWinner && isPuzzleSolved && !isNewTopScore){
  14.     doSomething();
  15. }
  16. ...
复制代码
下面就是在还没简化之前...

  1. if(a > b){
  2.     if(myScore > topScore){
  3.         if(totalMoves != 0){
  4.             doSomething();
  5.         }else{
  6.             doSomething();
  7.         }
  8.     }else{
  9.          doSomething();
  10.     }
  11. }
复制代码
看到分别了吧?可读性最重要。
本帖最后由 megablue 于 28-3-2013 07:20 PM 编辑

评分

参与人数 1人气 +5 收起 理由
fire-fly3 + 5 精品文章。 学到了。

查看全部评分

回复

使用道具 举报

发表于 28-3-2013 10:56 PM | 显示全部楼层
geekman 发表于 28-3-2013 11:30 AM
请学习使用正确的Code Formatting和Indentation,别学Microsoft那个蠢蛋工程师的坏习惯,把open bracket和 ...
(当然,switch也不是最佳选择。至于最佳选择是什么?这是秘密,商业秘密 )?

难道不是这个?
http://stackoverflow.com/questions/2596320/how-does-switch-compile-and-how-optimized-and-fast-is-it

The common way that compilers optimize a switch is to convert it to a jump table which can look something like:

if (condition1) goto label1;
if (condition2) goto label2;
if (condition3) goto label3;
else            goto default;
label1:
  <<<code from first ‘case statement`>>>
  goto end;
label2:
  <<<code from first `case statement`>>>
  goto end;
label3:
  <<<code from first `case statement`>>>
  goto end;
default:
  <<<code from `default` case>>>
  goto end;
end:


本帖最后由 gkheng2003 于 28-3-2013 10:59 PM 编辑

回复

使用道具 举报

发表于 29-3-2013 03:23 AM | 显示全部楼层
gkheng2003 发表于 28-3-2013 10:56 PM
难道不是这个?
http://stackoverflow.com/questions/2596320/how-does-switch-compile-and-how-opt ...

上面那组代码根本就是错误示范
只是一般的if-else 用上goto来实现罢了
这样做根本没差别,因为if-else 其实就是conditonal + goto (bracers)。

正真的jump table只需执行一次conditonal statement.
然后产生一个index value
然后再 goto (index value * code block size + table memory address) 。

说实在的,在大部分情况下,这种optimization 是不值得去做的... 以现在的CPU运算速度来说,想要以单纯的if-else来影响到程式的运行效能几乎是不可能. 现在的compiler 在绝大部分情况下都比我们聪明,没必要浪费生命去optimize这种performanc gain 少得不能再少的statment. 往往还会弄巧反拙,搞到更慢。

P/S: Wikipedia 有正确的jump table example, https://en.wikipedia.org/wiki/Jump_table#Jump_table_example_in_C

本帖最后由 megablue 于 29-3-2013 03:28 AM 编辑

回复

使用道具 举报


ADVERTISEMENT

发表于 29-3-2013 04:20 AM | 显示全部楼层
megablue 发表于 29-3-2013 03:23 AM
上面那组代码根本就是错误示范
只是一般的if-else 用上goto来实现罢了
这样做根本没差别,因为if- ...

人执着起来是很可怕的。

之前看到有人讨论, for loop用升式还是降式比较快。 看得我冷汗直流。

有趣的课题, 值得一看。
http://stackoverflow.com/questio ... y-faster-in-reverse  
本帖最后由 fire-fly3 于 29-3-2013 04:26 AM 编辑

回复

使用道具 举报

发表于 29-3-2013 09:37 AM | 显示全部楼层
gkheng2003 发表于 28-3-2013 10:56 PM
难道不是这个?
http://stackoverflow.com/questions/2596320/how-does-switch-compile-and-how-opt ...

请看13楼。
回复

使用道具 举报

发表于 29-3-2013 09:50 AM | 显示全部楼层
fire-fly3 发表于 29-3-2013 04:20 AM
人执着起来是很可怕的。

之前看到有人讨论, for loop用升式还是降式比较快。 看得我冷汗直流。 :f ...

优化 loop  我可以接受,至少这个真的会有很大的效能增益... 尤其是在JIT compiler.
可是,连++和--都拿来执着实在令人冒汗
总而言之,可以去了解、接触但无需太极端就是了, 你是programmer 不是compiler...

关于bracers (其实 parentesis也一样)
{补充一点是,每一次开{就立刻先关}, 中间的代码在关了bracer后再补上,这样做无论你的代码多复杂,你都不会遗漏掉}。

示范
  1. if(){}
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

 

ADVERTISEMENT



ADVERTISEMENT



ADVERTISEMENT

ADVERTISEMENT


版权所有 © 1996-2023 Cari Internet Sdn Bhd (483575-W)|IPSERVERONE 提供云主机|广告刊登|关于我们|私隐权|免控|投诉|联络|脸书|佳礼资讯网

GMT+8, 22-5-2024 06:33 AM , Processed in 0.077246 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表