Homework2

第一个程序的错误是i>0,i的取值应该是从0开始的,所以这里应该是i>=0。
test: x=null        does not execute the fault.
test: x=[2,3,2];y=2    executes the fault, but does not result in an error state.
test: x=[4,3,1];y=2    results in an error, but not a failure.

第二个程序的错误是for循环语句for (int i = 0; i < x.length; i++)这个语句找的是第一个0,应该是for (int i=x.length-1; i >= 0; i--)这个才是找最后一个0

test:x=null        does not execute the fault.
test:x=[0]        executes the fault, but does not result in an error state.
test:x=[1,2,0]        results in an error, but not a failure.

posted @ 2016-03-04 16:30  相儒以沫  阅读(116)  评论(0编辑  收藏  举报