/* (程式頭部注釋開始)
* 程式的版權和版本宣告部分
* 檔名稱: 十六周任務四
* 作 者: 石麗君
* 完成日期: 2012 年 6 月 5 日
* 版 本 號:
* 對任務及求解方法的描述部分
* 輸入描述:
要求編寫c++程式,讀wolfsheep.nls,去除其中所有的注釋,並儲存到檔案ws_nocomment.nls 中。
例如,wolfsheep.nls 中下面的一段**:
ask patches [ set pcolor green ]
; check grass? switch.
; if it is true, then grass grows and the sheep eat it. if it false, then the sheep don't need to eat
if grass? [
ask patches [
set countdown random grass‐regrowth‐time ; initialize grass grow clocks randomly
set pcolor one‐of [green brown]]]
經過處理後,在ws_nocomment.nls 中,上面劃線部分的注釋將全部不存在。
提示1:任務的另一種直白的解讀是:讀入每一行,複製每一行分號前面的部分。或者說,讀入每
一行,逐個複製檔案中的字元,如果出現分號,分號及其後的文字將不再複製。
* 問題描述:
* 程式輸出:
* 程式頭部的注釋結束
*/#include#includeusing namespace std;
int main()
{ ifstream readfile;
ofstream writefile;
char ch[200];int n;
readfile.open("wolfsheep.nls",ios::in);
writefile.open("ws_nocomment.nls",ios::out);
while(!readfile.eof())
{ readfile.getline(ch,200,'\n');
n=strlen(ch);
for(int i=0;i
第十六周專案四 英文單詞的基數排序
煙台大學計算機與控制工程學院 問題描述 設計乙個基數排序的演算法,將一組英文單詞,按字典順序排列。假設單詞均由小寫字母或空格構成,最長的單詞有maxlen個字母。輸入描述 無 輸出描述 若干資料 include include include define maxlen 9 單詞的最大長度 defi...
第十六周專案四 英文單詞的基數排序
問題及 煙台大學計算機與控制工程學院 作 者 孫麗瑋 完成日期 2016年12月12日 問題描述 設計乙個基數排序的演算法,將一組英文單詞,按字典順序排列。假設單詞均由小寫字母或空格構成,最長的單詞有maxlen個字母。include include include define maxlen 9 ...
第十六周 專案四 英文單詞的基數排序
問題描述及 煙台大學計控學院 作 者 邊朔 完成日期 2016年12月15日 問題描述 設計乙個基數排序的演算法,將一組英文單詞,按字典順序排列。假設單詞均由小寫字母或空格構成,最長的單詞有maxlen個字母。include include include define maxlen 9 單詞的最大...