How to perform an action every 5 results?

前端 未结 6 1499
春和景丽
春和景丽 2020-11-30 09:28

How can I perform an action within a for loop every 5 results?

Basically I\'m just trying to emulate a table with 5 columns.

6条回答
  •  孤街浪徒
    2020-11-30 09:52

    you could use the modulus operator

    for(int i = 0; i < 500; i++)
    {
        if(i % 5 == 0)
        {
            //do your stuff here
        }
    }
    

提交回复
热议问题