Trending News
c語言 library 的問題
最恨英文了,可是老師偏偏又出英文題,可以幫我看看我解釋的意思對嗎??
Create a library. The library should contain two functions, Hello() and World(). Calling the Hello() function should print out the string "Hello"; calling the World() function should print out the string "World".
------就是用c創造一個 library > Hello 跟World 呼叫的話就各印出來一次
The library should use a flag (implemented using a static global variable) that keeps track of which string was last printed. A call to the Hello() function should print out "Hello" only if "World" was the last string printed, and vice versa.
------- library 要有flag (不知道是不是註記的意思) Hello() 跟World ()要交互列印,(不能Hello()自己印兩遍) ------->很不確定
The flag should be updated at the end of each function call. Each function should return 1 if the string was printed, 0 otherwise. Write a simple program that uses the library and tests for the correct working of the functions.
-------- 呼叫這個 function 就會回傳 1 印完了就會回傳0
我對這個c語言題目的解釋是對的嗎??
1 Answer
- 戰神派大星Lv 57 years agoFavorite Answer
flag 是個確定執行狀況的變數 舉個例子:回傳值的0,1,... 都是回傳值的flag
0代表成功.. 其他代表失敗..每個都還有不一樣的失敗訊息
第二段要求這個flag看好哪一個字串是最後印出的而且呼叫hello函數
只有當world是最後的字串 才會印出hello 反之亦可
第三段要求每一次呼叫函數後要更新flag 如果字串有印出來 都要回傳1
沒有印出來就要回傳0
編寫一個簡單的程式 運用hello和world函數 並測試它們是否正確運行
有關flag 請參考