public class Test{ |
public static void main(String[] args) { |
int records = 101 ; //共有 101 条记录 |
final int GROUP_NUM = 10 ; //每组 10 条 |
int groups = ( int )Math.ceil( 1.0 *records/GROUP_NUM); //注意这里的 1.0,目的是要把类型变成 double 型的,而不是 int/int,结果还是 int,就错了。 |
System.out.println( "应该分的组数为=" +groups); |
} |
} //源代码片段来自云代码http://yuncode.net |
|