Re: [問題] 作業問題

看板C_and_CPP (C/C++)作者 (電腦小玩家)時間16年前 (2009/10/13 07:31), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《SOLID1127 ([SD])》之銘言: : 老師出的題目是 : 請列印出下列的結果 : Smile!!Smile!!Smile!! : Smile!!Smile!! : Smile!! : 特別註明只能用一個副函數 : 請問這題目是不是只能用迴圈解 : 因為老師還沒教到= = : 有人能不用迴圈就辦得到的嗎 : (我的原始碼) : #include<stdio.h> /*引入stdio.h*/ : #include<stdlib.h> /*引入stdlib.h*/ : void X(void); : int main(void) : { : X();X();X(); : X();X(); : X(); : system("pause"); /*請按任意鍵繼續的程式*/ : return 0; /*函數結束並回傳0,跳回原來呼叫的地方。*/ : } : void X(void) : { : printf("Smile!!"); : } : 當然這種結果是.. : Smile!!Smile!!Smile!!Smile!!Smile!!Smile!! : 哈哈 void printSmile(int nCurrentCount , int nTimes) { if(nCurrentCount>nTimes) return ; /* Print "Smile!!" */ printf("Smile!!"); if(nCurrentCount!=nTimes) { printSmile(nCurrentCount+1, nTimes); } else // End of condiction { printf("\n"); /* Next Line to print "Smile!!..." */ printSmile(1,nTimes-1); } } int main(int argc, char * argv[]) { /* @brief: printSmile(endCounts, firstCounts) , * print the first line with firstCounts Smile!! * , then second line with firstCoutns Smile!! ,... then * endCounts Smile!! * @Author: Allen * @Date : After eat breakfast ...Orz */ printSmile(1,3); return 0; } /* Try it for fun! ^_^ */ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.120.15.157

10/13 07:31, , 1F
好像太晚了。Orz...10/6的文章。XD
10/13 07:31, 1F
※ 編輯: allen501pc 來自: 140.120.15.157 (10/13 07:32)
文章代碼(AID): #1Aqxmv4W (C_and_CPP)
討論串 (同標題文章)
本文引述了以下文章的的內容:
4
12
完整討論串 (本文為第 2 之 2 篇):
4
12
文章代碼(AID): #1Aqxmv4W (C_and_CPP)