数据结构解析

数据结构自打刚开始上学到工作都是吹牛、侃大山必备神器。所以一直都要保持总结和提高。


0x00 数据结构三大马车
数据模型定义,数据模型操作, 数据显示

数据模型定义:由单一弱数据类型,变成了由多个弱数据类型组成的强类型

typedef struct tag_data{
	char name[20];
	int Mathematics;
	int Chinese;
}student;


数据模型操作:对数据进行业务操作

/******
@@describe:		求两门成绩的平均成绩
@@parameter:	student* pstStudent
@@return: 		-1:功能调用失败
*/
int CalculationAvgScore(student* pstStudent)
{
	if (NULL == pstStudent)
	{
		printf("pstStudent is null! \n");
		return -1;
	}

	int outScore = (pstStudent->Chinese + pstStudent->Mathematics) / 2;
	return  outScore;
}

0x01 实例代码

//业务实现:分数总和、平均分


//数据结构定义
typedef struct tag_data{
	char name[20];
	int Mathematics;
	int Chinese;
}student;


/******
@@describe:	计算平均分成绩
@@parameter:	student* pstStudent
@@return: 		-1:功能调用失败
*/
int CalculationAvgScore(student* pstStudent)
{
	if(NULL ==  pstStudent)
	{
		printf("pstStudent is null! \n");
		return -1;
	}


	int outScore = (pstStudent->Chinese + pstStudent->Mathematics)/2;
	return  outScore;
}


/******
@@describe:	计算总分成绩
@@parameter:	student* pstStudent
@@return: 		-1:功能调用失败
*/
int CalculationTotalScore(student* pstStudent)
{
	if(NULL ==  pstStudent)
	{
		printf("pstStudent is null! \n");
		return -1;
	}


	int outScore = (pstStudent->Chinese + pstStudent->Mathematics);
	return  outScore;	
}


int main()
{
	struct student guazi{1,"guazi", 85,94};
	
	//显示数据处理后的结果
	printf("avg score:%d \n", CalculationAvgScore(&guazi));
	
	printf("total score:%d \n", CalculationTotalScore(&guazi));
	return 0;
}

0x002 经验

瓜子以前写代码也是:老夫就是一把梭,复制,黏贴,就是干。效率虽然高,但也是经验浅薄,没少返工,离职也对

以前工作进行了总结,如何有经验的进行代码功能的开发:

1.先分析清楚业务需求。

2.功能函数伪代码编写

3.编写功能代码

4.进行功能代码测试

5.编写测试文档

6.上传功能代码到服务器

7.提交功能任务进度

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值