CSI讲义14--编程作业格式要求

2018-10-07  本文已影响435人  Bintou老师

命名方法

不要使用拼音。文件名尽量避免使用中文。

变量

不要使用拼音,不要使用单字符变量,循环控制变量除外。一般,小写字符开头,两个单词组成则第二个词大写开头。比如:

常量

全大写字符的单词。

函数名

函数名大写字符开头,多个单词组成,单词开头大写字符。如果是判断函数,以“Is”或“Are”开头,比如IsPrime。阶乘为Factorial。详细注释函数的功能与定义。

/*
* Input: an integer n
* Output: n's factorial, integer
* Purpose: ****
* Method: *****
*/
int Factorial(int n){

}

指针

指针变量以“_p”结尾。比如,node_p 。

用户定义类型

以“_t”结尾。

注释

保持适当的注释。尽可能不要使用中文进行注释,除非老师要求。

缩进方式

请严格进行缩进!平行语句要对齐。

程序框架

建议使用以下框架。

/*
* File: AddTwoNums.c
* Author: Libin Wang
* Date: 20181007
*
* Purpose: to solve a problem in LeetCode:
* https://leetcode.com/problems/add-two-numbers/description/
*/

#include <stdio.h>
#include <stdlib.h>

/**
 * Definition for Data Type
 */
struct ListNode {
    int val;
    struct ListNode *next;
 };

/**
* Declaration of functions.
**/
void printList(struct ListNode* node);
void insertList(struct ListNode **list, struct ListNode *node);
struct ListNode* AddTwoNums(struct ListNode* l1, struct ListNode* l2);

int main(){
     /**
       * Definition for variables.
     **/
    struct ListNode *l1, *l2, *new_list;
    struct ListNode *node;

}
上一篇 下一篇

猜你喜欢

热点阅读