⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 touwenjian2.h

📁 这是数据结构习题书上实验四的一个程序,可以下载来
💻 H
字号:
int funnum(struct linkst list)
//计算程序中所包含的函数个数
{
	int i,j,w=0;
	for(i=1;i<=list.mrow;i++)
		for(j=0;j<list.date[i].character;j++)
			if(list.date[i].ch[j]=='{')  w++;
	return(w);
}


int accountfun(struct linkst list)
//计算程序中每个函数所占行数
{
	int i,j,t,w=0,q,n;
	q=funnum(list);
	struct sqstack s;
    s.base=(ElemType *)malloc(MAXS * sizeof(ElemType));
	s.top=s.base;
	s.stacksize=MAXS;
	s.top->c='@';
	s.top->row=0;
	for(i=1;i<=list.mrow;i++){
		for(j=0;j<list.date[i].character;j++){
			if(list.date[i].ch[j]=='{'){
				s.top->c=list.date[i].ch[j];
				s.top->row=list.date[i].row;
				s.top++;
			}
			if(list.date[i].ch[j]=='}'){
				w++;
				if(s.top != s.base){
					s.top--;
					t=list.date[i].row-s.top->row+1;
					n=q-w+1;
					printf("第%d个函数,共%d行\n",n,t);
				}
			}
		}
	}
	return(w);
}

float CountFunAver(int sum,int funnumber)
//计算程序中函数的平均行数
{
	float average,sum1;
	sum1=(float) sum;
	average=sum1 / funnumber;
	return average;
}

void JudgeFun (float codeaver,float remark,float blank,float total)
//评价函数风格
{
	float x,y,z,x1,y1;
	z=(codeaver / total) * 100;
	x=remark /total;
	y=blank /total;
	x1=100 * x;
	y1=100 * y;
	printf("Code            Comments           Space\n\n");
	printf("========      =============       ============\n\n");
	printf("%7.2f%%",z);
	printf("         %7.2f%%",x1);
	printf("           %7.2f%%\n",y1);
	if(codeaver<=15.5 && codeaver>=9.5) 	printf("代码等级为A\n");
	else if(codeaver>=7.5 && codeaver<9.5 || (codeaver<=20.5 && codeaver>15.5))printf("代码等级为B\n");
	else if((codeaver>=5.0 && codeaver<7.5) || (codeaver>20.5 && codeaver<=24.0)) printf("代码等级为C\n");
	else if(codeaver>24.0 ||codeaver<5.0) printf("代码等级为D\n");
	//估计函数代码风格等级
	if(x<=0.25 && x>=0.15) printf("注释比率等级为A\n");
	else if((x<0.15 && x>=0.10) || (x<=0.30 && x>0.25))printf("注释比率等级为B\n");
	else if((x<0.10 && x>=0.05) || (x<=0.35 && x>0.30))printf("注释比率等级为C\n");
	else if(x<0.05 || x>0.35) printf("注释比率等级为D\n");
	//估计函数注释行代码等级
	if(y<=0.25 && y>=0.15)printf("空行比率等级为A\n");
	else if((y<0.15 && y>=0.10) || (y<=0.30 && y>0.25)) printf("空行比率等级为B\n");
	else if((y<0.10 && y>=0.05) || (y<=0.35 && y>0.30)) printf("空行比率等级为C\n");
	else if(y<0.05 || y>0.35)printf("空行比率等级为D\n");
	//估计函数空行代码等级
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -