Finding the function complexity index

2019-07-06 21:56发布

问题:

I have to find the complexity of a C file based on the number of lines. I have found the number of lines. But how to decide whether it is a complex file or not? Based on certain value, I have to give it an index. For eg., complexity index - 5 for high complexity. On which basis can I index it? More than 1000 lines for high complex, for eg., won't apply for all. Is there any standard way for giving conditions('more than 1000 lines')? Any kind of suggestions are welcome, except any pre-defined tools. I need to program it in C. Thanks in advance.

回答1:

comlexity is not based on lines, for example:

while(n!=0) {a+=b;n--;}

the complex is n and another exapmle:

for(i=0;i<n;i++) {for(j=0;j<n;j++) {a+=b} }

the complexity is n^2