科目名稱:資訊系統 與網路導論 | 開課系所:資訊工程 學系 | 任課教師 |
吳坤熹 |
||
系所別: |
年級: |
學號: |
姓名: |
考試日期 |
2008.12.3 |
(考試時間: 14:10-14:30)
#include <iostream>
using std::cout;
using std::endl;
int main() // Bubble Sort
{
int i, j, temp;
int a[] = { 1, 9, 6, 3};
const int K = sizeof(a) / sizeof(a[0]);
for (i=0; i<K; i++)
for (j=K-1; j>i; j--)
if (a[j-1] > a[j])
{
temp = a[j-1];
a[j-1] = a[j];
a[j] = temp;
}
for (i=0; i<K; i++)
cout << a[i] << endl;
}
#include <iostream>
using std::cout;
using std::endl;
int main()
{
const int N = 2;
int i, j, k;
int a[N][N] = { {1, 2}, {3, 4} };
int b[N][N] = { {5, 6}, {7, 8} };
int c[N][N] = { 0 };
for (i=0; i<N; i++)
for (j=0; j<N; j++)
for (k=0; k<N; k++)
c[i][j] += a[i][k]*b[k][j];
for (i=0; i<N; i++)
{
for (j=0; j<N; j++)
cout << c[i][j] << "\t";
cout << endl;
}
}