日期:2014-05-20 浏览次数:20678 次
int[] ary = new int[100]; int sum1 = 0; int sum2 = 0; for (int i = 0; i < ary.length; i++) { sum1 += i + 1; sum2 += ary[i]; } int rs = sum1 - sum2;
------解决方案--------------------
int[] ary = new int[99]; //给ary的每一个元素赋值...... int x = 5050; //写成int sum=(100+1)*100/2;也行. for (int i = 0; i < ary.length; i++) { x-=ary[i]; } System.out.println("那个数是:"+x);