标签:error expect expec test ati should logs change fail
给出的题目如下:
我的解答如下:
For program 1:
1.
where i > 0 is the fault , it should be changed to i>= 0 to avoid x is just one element situation.
2.x[] ={} or x[]={n}(n is equal to any numb),for example x[] ={1};
//test: x[] = {};y =2
//expected = NullPointerException; output = NullPointerException
3.
//test:x[] ={3 2 5} ; y = 2
//expected = 1; output = 1
4.
//test:x[] ={3} ; y = 2
//expected = -1; output = -1
For program 2:
1.
where the for loop is to get the first ZERO in array, it should be changed to
for(int i = x.length -1; i >= 0; i --)
2.
it is impossible, cause it doesn‘t belong to the fault. Its code is to get the First ZERO NOT LAST
3.
//test:x=[2 1 0]
//expect = 2; output = 2
4.
//test:x=[0 1 2]
//expect = 0 ; output = 0
标签:error expect expec test ati should logs change fail
原文地址:http://www.cnblogs.com/JMarshall/p/6443779.html