第十二周 OJ A遞迴方法實現逆序

2021-07-24 19:28:16 字數 541 閱讀 5728

問題及**:

/*

檔名稱:test.cpp

完成日期:2023年11月22日

版本號:v1.0

題目描述:

你知道遞迴麼?簡單來說,遞迴就是函式自身對自身的呼叫,直到遇到終止條件,再對資料做逆向處理,下面就有乙個遞迴的簡單例子等你來處理。

輸入乙個int型整數

輸出轉換後的整數

樣例輸入

1234567

樣例輸出

7654321

*/#include void inverted(int); /*函式宣告*/

int main()

void inverted(int n)

else/*從後往前除以10取餘輸出,即當前n的最後一位*/

return;

}

執行結果:

知識點總結:

學習心得:

第十二周遞迴方法實現逆序

你知道遞迴麼?簡單來說,遞迴就是函式自身對自身的呼叫,直到遇到終止條件,再對資料做逆向處理,下面就有乙個遞迴的簡單例子等你來處理。include void inverted int 函式宣告 int main void inverted int n 從後往前除以10取餘輸出,即當前n的最後一位 請在...

第十二周專案2 2 遞迴函式

問題及 檔名稱 test.cpp 作 者 陳文青 完成日期 2014年11月16日 版 本 號 v1.0 問題描述 寫出求1 3 n的遞迴式,並編寫出遞迴函式求解。程式輸入 乙個整數,n 程式輸出 乙個長整型 y,表示n以內的奇數積 include using namespace std long ...

第十二周作業

例題1 includeusing namespace std struct date struct student int main stu1,stu2 stu1.num 1001 stu1.age 20 stu2 stu1 cout includeusing namespace std struc...