2014年下半年软件评测师下午真题(含答案)试题一(共20分)阅读下列C程序,回答问题1至问题3,将解答填入答题纸的对应栏内
ﻫ【C程序】intGetMaxDay(intyear,intmonth){intmaxday=0;//1ﻫif(month>=1&&month<=12){//2,3ﻫif(month==2){//4if(year%4==0){//5if(year%100==0){//6if(year%400==0)//7ﻫmaxday=29;//8else//9ﻫmaxday=28;ﻫ}ﻫelse//10maxday=29;ﻫ}elsemaxday=28;//11}ﻫelse{//12if(month=4||month=6||month=9||month=11)//13,14,15,16maxday=30;//17else//18maxday=31;}ﻫ}returnmaxday;//19}【问题1】(6分)请针对上述C程序给出满足100%DC(判定覆盖)所需的逻辑条件
ﻫ【问题2】(9分)请画出上述程序的控制流图,并计算其环路复杂度V(G)
ﻫ【问题3】(5分)请给出问题2中控制流图的线性无关路径
参考答案:【问题1】:ﻫMonth>=1&&month<=12ﻫMonth==2ﻫYear%4==0ﻫYear%100==0Year%400==0ﻫMonth==2ﻫMonth==4ﻫMonth==6ﻫMonth==9Month==11【问题2】:ﻫV(G)=11【问题3】:1、2ﻫ1、2、31、2、3、4、12、13、17、191、2、3、4、12、13、14、17、191、2、3、4、12、13、14、15、17、19ﻫ1、2、3、4、12、13、14、15、16、17、191、2、3、4、12、13、14、15、16、18、19ﻫ1、2、3、4、5、11、191、