用遞歸的方法判斷整數組a[N]是不是升序排列

 

/*用遞歸的方法判斷整數組a[N]是不是升序排列
*/
int is_ascending(int a[],int length){

 if(length==1)return 1;
 if (a[length-1]>a[length])
 {
  return 0;
 }else
 {
  return is_ascending(a,length-1);
 }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章