f(x)=-x^2-2x=-(x+1)^2+1,-2≤x≤0;f(x)max=1,f(x)min=0
f(x)=x,0<x≤2,f(x)max=2,f(x)min=0
综上,f(x)max=2,f(x)min=0