如有311人,我指定30人一个考室,
那么系统自动算出311人,需要11个考室,上面的条件我都知道了,下面的这个怎么算出呢?1-10考室30人,11考室11人1考室              30个人
……               ……一直到11考室的时候 推断是 11人怎么实现

解决方案 »

  1.   

    select top 30 from tablename where studentid not in(select top 30*10 studentid from tablename) --30*10必须写成300,这需要使用动态语句来执行
      

  2.   

    或者:
    int total = 311;
    int currentRoom = 11;
    int numberPerRoom = 30;
    if total>=currentRoom *numberPerRoom;
        return numberPerRoom;
    else if(total <= (currentRoom-1)*numberPerRoom)
        return 0;
    else
        return total-(currentRoom-1)*numberPerRoom;
         
      

  3.   

     int total = 311;
                int i = 1;
                for (; i < total / 30; i++)
                {
                    Console.WriteLine("第{0}房是30人", i);
                }
                if (total % 30 != 0)
                {
                    Console.WriteLine("第{0}房是{1}人", i, total % 30);
                }