國立暨南國際大學 100 學年度第一學期小考試卷
科目名稱:資訊系統
與網路導論 |
開課系所:資訊工程
學系 |
任課教師
|
吳坤熹
|
系所別:
|
年級:
|
學號:
|
姓名:
|
考試日期
|
2011.10.19
|
(考試時間: 14:30-14:40)
-
(10%) What will the following code display?
#include <iostream>
using std::cout;
using std::endl;
int main()
{
char name[] = "NCNU";
unsigned mask = 0x20;
cout << name << endl;
for (int i=0; i<4; i++)
name[i] |= mask;
cout << name << endl;
return 0;
}
-
(10%)
What will the following code display?
#include <iostream>
#include <iomanip>
using std::cout;
using std::endl;
using std::setw;
int main()
{
const int k=3;
int a[k][k] = { {1,2,3}, {3,4,5}, {5,6,7} };
int i, j;
for (i=0; i<k; i++)
{
for (j=0; j<k; j++)
cout << setw(3) << a[i][j];
cout << endl;
}
for (i=0; i<k; i++)
for (j=0; j<k; j++)
a[i][j] *= ( (i+j)%2 ?-1:1 );
cout << endl;
for (i=0; i<k; i++)
{
for (j=0; j<k; j++)
cout << setw(3) << a[i][j];
cout << endl;
}
return 0;
}