consultation: Mon 4:15-5:15pm ( week 3-10 )
Fri 2-3pm ( week 1-10 )
lab: Fri 12-1pm ( CSE Drum Lab, B08 in K17 basement, David )
前两次作业不计分(Moodle),每次作业两分,单数周题目,双数周code练习,deadline都是Monday11am
期中考试网上考试,12分,选择题加简答题,1小时
期中之后assignment,12分,deadline在第10周
期末选择题简答题,double pass
1. B was a typeless language, C is a typed language
2. in the main function, return 0 means the code run successfully
3. 对给出数组进行从小到大排序的算法是,从第二个数开始依次跟左边的数进行比较(重复比较),将更大的放到后面,直到遍历完所有的数
1 #include <stdio.h> //include standard I/O library defs and functions 2 #define SIZE 6 //define a symbolilc constant 3 void insertionSort(int array[],int n) //functions headers must provide types 4 { 5 int i; //each variable must have a type 6 for (i=1; i<n; i++) 7 { 8 int element=array[i]; 9 int j=i-1; 10 while (j>=0 && array[j]>element) 11 { 12 array[j+1]=array[j]; 13 j--; 14 } 15 array[j+1]=element; 16 } 17 } 18 int main(void) //main:program starts here 19 { 20 int numbers[SIZE]={3,6,5,2,4,1}; 21 int i; 22 insertionSort(numbers,SIZE); 23 for(i=0; i<SIZE; i++) 24 printf("%d ", numbers[i]); //printf defined in stdio 25 return 0; 26 }
4. void是没有返回值的函数
5. i++ means i=i+1 ( now you can understand C++ )
6. && means and
7. 循环语句里只有一句话时可以不加{},如代码中第24行
8. 使用gcc:
To compile a program prog.c, type:
prompt$ gcc prog.c
To run the program, type:
prompt$ ./a.out
#editor不做要求,老师使用的是emacs, 建议使用带有highlighting功能的,更加醒目
9. 尽量使用第一种,不推荐第二种
10. assignment(赋值)可以与循环结合