[問題] 請問錯誤在哪裡

看板C_and_CPP (C/C++)作者 (moi)時間16年前 (2009/06/11 11:21), 編輯推噓2(201)
留言3則, 3人參與, 最新討論串1/1
#include <cstdlib> #include <iostream> #include<stdio.h> using namespace std; void towers(int,char,char,char); char frompole,topole,auxpole ; main() { int n; scanf("%d",&n); towers(n,'a','c','b'); system("PAUSE"); return EXIT_SUCCESS; } towers(n,frompole,topole,auxpole) { int n; if(n==1){ printf("%s%c%s%c%s","move disk 1 from",frompole,"pole to",topole,"pole"); return;} towers(n-1,frompole,auxpole,topole); printf("%s%d%s%c%s%c%s","move disk",n,"from",frompole,"pole to",topole,"pole"); towers(n-1,auxpole,topole,frompole); } 上面的程式編譯後出現錯誤在副程式towers的那一行,錯誤是18 C:\Dev-Cpp\hannoi.cpp expected `,' or `;' before '(' token 請問哪裡出錯了呢?謝謝~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.69.95.3

06/11 11:23, , 1F
這不是很明顯嗎
06/11 11:23, 1F

06/11 11:23, , 2F
1.towers沒有回傳值 2.參數沒有形態 3.這錯很大喔...
06/11 11:23, 2F

06/11 11:54, , 3F
不好意思我已經調整好了,謝謝janfang大^^
06/11 11:54, 3F
文章代碼(AID): #1AC7X0e4 (C_and_CPP)
文章代碼(AID): #1AC7X0e4 (C_and_CPP)