/*思路:首尾互換往中間直到交換到中間*/#include"stdio.h"voidfun(int*d,intstart,intlast){inttemp;if(start<last/2){temp=*(d+start);*(d+start)=*(d+last-start-1);*(d+last-start-1)=temp;//printf("%d%d",start,last-start-1);fun(d,start+1,last);}elsereturn;}intmain(){intd[1024];inti,j;i=0;printf("輸入一組正整數:");scanf("%d",&d[i]);i=i+1;while(d[i-1]>0){if(scanf("%d",&d[i])>0)i=i+1;elsebreak;}if(d[i-1]<=0)i=i-1;fun(d,0,i);for(j=0;j<i;j++)printf("%d",d[j]);}
/*思路:首尾互換往中間直到交換到中間*/#include"stdio.h"voidfun(int*d,intstart,intlast){inttemp;if(start<last/2){temp=*(d+start);*(d+start)=*(d+last-start-1);*(d+last-start-1)=temp;//printf("%d%d",start,last-start-1);fun(d,start+1,last);}elsereturn;}intmain(){intd[1024];inti,j;i=0;printf("輸入一組正整數:");scanf("%d",&d[i]);i=i+1;while(d[i-1]>0){if(scanf("%d",&d[i])>0)i=i+1;elsebreak;}if(d[i-1]<=0)i=i-1;fun(d,0,i);for(j=0;j<i;j++)printf("%d",d[j]);}