?? touwenjian2.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 + -