谁能帮我写一下保龄球单人比赛单局得分的算法~~~小弟在这里感激不尽..

解决方案 »

  1.   

    各位大哥,
    看一下如下说明,帮我解答一下吧.http://www.bowling.com.cn/zypd/jsgz.htm
      

  2.   

    int score[]={9,1,6,3,8,2,7,2,10,0,10,0,10,0,4,5,8,2,10,0,7,3}; int totalSrore=Score(score);即可
    方法:
    // 传入22长的数组
    // 前20个数为 正常10格 后2个为加格;
    // 1投中5,2投中4 记为 5 4
    // 1投中6,2投补中 记为 6 4
    // 1投全中        记为 10 0
    // 已按上述规则页给出的数据测试,结果173;public int Score(int[] s)
    {
    int t[]={1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0};
    for (int i=0;i<20;i++,i++)
    {
    if (s[i]==10)
    {
    t[i+2]++;
    t[i+((s[i+2]==10&&i<18)?4:3)]++;
    }
    else if(s[i]+s[i+1]==10) t[i+2]++;
    }
    int score=0;
    for (int i=0;i<22;i++)
    score+=s[i]*t[i];
    return score;
    }