题目一:
1. 编写冒泡排序程序
要求:
1) 请用c#编写一个冒泡排序的程序,
2) 要求排序的数据从文件c:\data.dat中读取,数据间用逗号分隔。
解:
using system;
using system.io;
class test{
static void bubblesort(int[] ai) {
for (int j = ai.length - 1; j > 0; j--){ // outer loop (backward)
for (int i = 0; i < j; i++) // inner loop (forward)