有这样一个题目,给出了一个一维整型数组,要求对其进行倒置后然后输出!有可能以下的解决办法,如果有更好的解决办法欢迎回复说明! 1234567891011121314151617181920212223 public static void reverse(int x[]){ int foot=0; int head=0; if(x.length%2==0){ foot=x.length/2; head=foot-1; for(int i=0; i int temp=x[head]; x[head]=x[foot]; x[foot]=temp; head--; foot++; } }else{ foot=x.length/2; head=foot; for(int i=0; i int temp=x[head]; x[head]=x[foot]; x[foot]=temp; head--; foot++; } }} 赞微海报分享
近期评论