看板 NTUE-CS102 關於我們 聯絡資訊
嘛...... 雖然學長說不適用遞迴,但是我這死腦筋完全想不到不用遞迴的話要怎麼寫(汗 以下有錯請鞭,小力點......(抖 PS:經過學長指示邏輯錯誤之處,終於可以cout正確答案(淚 --------------------------------------- #include<iostream> using namespace std; int I(int x) { int i=0, j=0; if (x < 2) return (1); else for (i=0; i<x; i++) { j = j+I(i)*I(x-1-i); } return (j); } int main() { int A[12]; A[0] =1; A[1] =1; for (int x=0; x<12; x++) { A[x] = I(x); } for (int i=0 ;i<12 ;i++) cout << A[i] << endl; } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.229.216.237 ※ 編輯: up45678 來自: 61.229.216.237 (01/19 21:49)