Re: [問題] 這題目要的意思是??
※ 引述《LPH66 (-858993460)》之銘言:
: ※ 引述《kissmypenis (紅豬)》之銘言:
: : 我是個初學C語言的高中生...
: : 最近在寫一些簡單的程式
: : 老師出了一些題目當作業..其中一題為以下
: : 題目: Printing patterns 。
: : a. Write a function with the header
: : Void line(int n , char c)
: : Which will print n copies of the character c followed by a new line.
: : b. Use this function in a program which reads in an integer and prints a
: : triangle of the specified number of lines,in the following format:
: : How main lines? 4
: : *
: : **
: : ***
: : ****
: : c. Use this function in a program which reads in an integer and prints a
: : triangle of the specified number of lines,in the following format:
: : How main lines? 5
: : *********
: : *******
: : *****
: : ***
: : *
: : b跟c兩題我用for迴圈的方式可以寫得出來...我看不太懂a是要我寫甚麼???
: : 有利害的大大可以跟我解說嗎? 謝謝 ^^
: 這三題是個題組
: 後兩題其實是要你用第一題寫的函式來回答
: 而第一題是這樣的: 要你寫一個叫 line 的函式
: 長得像 void line(int n, char c)
: 要能夠在呼叫它之後印出 n 個字元 c 附帶一個換行
void line(int n, char c) {
while (n--)
putchar(c);
putchar('\n');
}
給一個簡單的答案
剩下的部份就用這個 line() 來完成
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 210.60.107.233
→
10/18 12:59, , 1F
10/18 12:59, 1F
→
10/18 12:59, , 2F
10/18 12:59, 2F
→
10/18 13:02, , 3F
10/18 13:02, 3F
→
10/18 13:06, , 4F
10/18 13:06, 4F
推
10/18 13:07, , 5F
10/18 13:07, 5F
討論串 (同標題文章)