c 第一次作業

2021-07-01 18:53:04 字數 784 閱讀 7960

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.threading.tasks;

using system.io;

using system.text.regularexpressions;

using system.collections;

namespace check_3_1

public static void calculate()

else //判定是檔案

bool note = false;

//用於判斷注釋中的/**/

for (int j = 0; j < n; j++)

//當選項一輸入為乙個檔案而非目錄時,只執行一次

else if (sum.startswith("/*") && !sum.endswith("*/"))

//注釋行

else if (note == true)

}else if (sum.startswith("//"))

else

//除了上述情況都視為**行}}

catch (exception e)

sr.close();}}

catch (exception e)

finally}}

console.read();

//僅用於編譯之後滯留在控制台而非閃退}}

}

c 第一次作業

要求 計算 的注釋行,行,空行和總行數。步驟解析 先開啟檔案,讀取檔案,因為注釋行開頭以 或者 開頭,所以有 或者 的行為注釋行。空行就是什麼都沒有的,為空的。行就是有 的,實現這些功能的過程中需要用到trim這個函式。如下 using system using system.collections...

c 第一次作業

c 第一次作業 一 程式設計分析題。1.分析程式寫出結果 x,y 15,25 x,y 15,25 x,y 15,25 x,y 14,26 include using namespace std voidf1 int x,int y voidf2 int x,int y voidf3 int x,in...

C 第一次作業

c 作業1 編寫乙個程式,要求從螢幕輸入你的名字和年齡,在螢幕顯示你的名字和你明年的年齡。include include using namespace std intmain 在螢幕上輸入兩個整數,求兩個數的差,並將結果運算出來。include include using namespace st...