資訊處理 94 年程式語言概要考古題(共 5 題) 資料來源:考選部歷屆試題|法律人 LawPlayer 整理 https://lawplayer.com/exam/information-processing/94-%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80%E6%A6%82%E8%A6%81 第 1 題 寫出下列C 程式之執行結果:(20 分) main() { int a,b,c,d,e; a=b=c=d=e=3; a+=b-=c*=d=e+=2; printf("%d %d %d %d %d\n", a, b, c, d, e); a += (b+=c) + (e-=2) – 1; printf("%d %d %d %d %d\n", a, b, c, d, e); } 第 2 題 寫出下列C++程式之執行結果:(20 分) #include main() { int i,j; for (i=1; i<5; i++) { for (j=1; j<5; j++) { cout << '=' << 3*i*j-i-j << ' '; if (i+j==5) cout << "** "; } cout << endl; } } 第 3 題 Java 程式語言中,class 內的static 與非static 欄位(fields)有何不同?請舉例說明其 不同之用法。(20 分) 第 4 題 試寫出以下片段程式(用C/C++/Java 都可),使得兩變數x 及y 的數值互換。(20 分) int x,y,temp; ... /* x 及y 數值已在此設定好了 */ /* 請在此處寫出片段程式,使得兩變數x 及y 的數值互換 */ ... /* x 及y 數值已交換 */ 第 5 題 對上題,試寫出不用temp 變數的程式,來使得兩變數x 及y 的數值互換。(20 分) 題目為考試當年公告版本,實務標準請以現行規範為準。