Making code shorter

后端 未结 5 519
感动是毒
感动是毒 2021-01-26 16:28

I\'m currently building a program and I\'m trying to make my code a bit shorter. It\'s just a for-loop repeating itself 15 times. Can someone show me how they would do it and ex

5条回答
  •  [愿得一人]
    2021-01-26 16:48

    Here is the shorter version. Try it if you find it useful,

    for (i=0; i<1296; i++)
    {
        for (int k=0; k<15; ++k)
        {
            s[0]=0;
            s[4]=k;
            for (j=0; j<1296; j++)
            {
                counter = 0;
                if (remain[j][0]!=-1)
                {
                    feed(poss[i], remain[j], f);
                    if (f[0]==s[0] && f[4]==s[4])
                    {
                        counter++;
                    }
                }
                table[i][k]=counter;
            }
        }
    }
    

提交回复
热议问题