軟件測試工_程師問答集考試卷模擬考試題_第1頁
軟件測試工_程師問答集考試卷模擬考試題_第2頁
軟件測試工_程師問答集考試卷模擬考試題_第3頁
軟件測試工_程師問答集考試卷模擬考試題_第4頁
免費預(yù)覽已結(jié)束,剩余18頁可下載查看

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、姓名:_ 班級:_ 學(xué)號:_-密-封 -線- 軟件測試工_程師問答集考試卷模擬考試題考試時間:120分鐘 考試總分:100分題號一二三四五總分分數(shù)遵守考場紀律,維護知識尊嚴,杜絕違紀行為,確??荚嚱Y(jié)果公正。1、已知c源程序如下:/*input todays date,output tomorrowsdate*/*version 2*/#includestdio.hstruct ydate int day;int month;intyear;int leap(struct ydate d)if(d.year%4=0&d.year%100!=0)|(d.year%400=0)return 1; e

2、lsereturn0;int numdays(struct ydate d) int day; static int daytab=31,28,31,30,31,30,31,31,30,31,30,31);if(leap(d)&d.month=2)day=29;elseday=daytabd.month-1; returnday;int main(void)struct ydate today,tomorrow; printf(“format of dateis:year,month,day 輸入的年、月、日之間應(yīng)用逗號隔開/n”); printf(“todayis:”);scanf(“%d,

3、%d,%d”,&today.year,&today.month,&today.day); while(0=today.year| today.year65535 |0=today.month | today.month12) |0=today.day |today.daynumdays(today) printf(“input date error!reenterthe day!/n”);printf(“today is:”);scanf(“%d,%d,%d”,&today.year,&today.month,&today.day);if(today.day!=numdays(today)to

4、morrow.year=today.year;tomorrow.month=today.month;tomorrow.day=today.day+1;else if(today.month=12)tomorrow.year=today.year+1;tomorrow.month=1;tomorrow.day=1;elsetomorrow.year=today.year;tomorrow.month=today.month+1;tomorrow.day=1;printf(“tomorrow is:%d,%d,%d/n/”,tomorrow.year,tomorrow.month,tomorrow

5、.day);畫出程序中所有函數(shù)的控制流程圖;( )2、已知c源程序如下:/*input todays date,output tomorrowsdate*/*version 2*/#includestdio.hstruct ydate int day;int month;intyear;int leap(struct ydate d)if(d.year%4=0&d.year%100!=0)|(d.year%400=0)return 1; elsereturn0;int numdays(struct ydate d) int day; static int daytab=31,28,31,30,

6、31,30,31,31,30,31,30,31);if(leap(d)&d.month=2)day=29;elseday=daytabd.month-1; returnday;int main(void)struct ydate today,tomorrow; printf(“format of dateis:year,month,day 輸入的年、月、日之間應(yīng)用逗號隔開/n”); printf(“todayis:”);scanf(“%d,%d,%d”,&today.year,&today.month,&today.day); while(0=today.year| today.year655

7、35 |0=today.month | today.month12) |0=today.day |today.daynumdays(today) printf(“input date error!reenterthe day!/n”);printf(“today is:”);scanf(“%d,%d,%d”,&today.year,&today.month,&today.day);if(today.day!=numdays(today)tomorrow.year=today.year;tomorrow.month=today.month;tomorrow.day=today.day+1;els

8、e if(today.month=12)tomorrow.year=today.year+1;tomorrow.month=1;tomorrow.day=1;elsetomorrow.year=today.year;tomorrow.month=today.month+1;tomorrow.day=1;printf(“tomorrow is:%d,%d,%d/n/”,tomorrow.year,tomorrow.month,tomorrow.day);設(shè)計一組測試用例,使該程序所有函數(shù)的語句覆蓋率和分支覆蓋率均能達到100%。如果認為該程序的語句或分支覆蓋率無法達到100%需說明為什么。( )

9、3、已知c源程序如下:/*a simple mailing list example using an array ofstructures. */# includestdion.h#includestdlib.hdefine max 4structaddrchar name30;charstreet40;char city20;unsigned longint zip;addr_listmax;voidinit_list(void),enter(void);voiddeleteaddr(void),list(void);intmenu_select(void),find_free(void)

10、;int main(void)char choice;init_list( );/*initialize the structure array*/for(;)choice=menu_select( );switch(choice)case1:enter( );break;case 2:deleteaddr( );break;case 3:list( );break;case 4:exit(0);return 0;/*initialize the list.*/void initlist(void)register int t;for(t=0;tmax; +t)addr_listt, name

11、0=/0;/*get a menu selection. */int menu_select(void)char s80. ;int c;printf(“1enter aname/n”);printf(“2delete a name/n”);printf(“3list the file/n”);printf (“4quit/”)doprintf(“/nenter yourchoice:”);gets(s);c= atoi(s);while(c1 | c4);returnc;/*input addresses into the list.*/void enter(void)intslot;cha

12、r s80;slot=find_free( );if(slot=-1)printf(“/nlist full”);return;printf(“entername:”);gets(addr_);printf(“enter street:”);gets(addr_listslot.street);printf(“entercity:”);gets(addr listslot.city);printf(“enter zip:”);gets(s);addr_listslot.zip=strtoul(s,/0,10);/*find an unused structure. *

13、/intfind_free(void)register intt;for(t=0; addr_listt. name0&tmax;+t);if(t=max)return-1; /*no slots free*/return t;/*delete an address.*/void deleteaddr(void)register int slot;char s80;printf(“enter record#: “);gets(s);slot=atoi(s);if(slot=0 &slotmax)addr_listslot. name0=/0;/*display the list on the

14、screen. */void list(void)register intt;for(t=0; tmax; +t)if(addr_listt. name0)printf(“%s/n”, addr_listt. name);printf(“%s/n”, addr_listt. street);printf(“%s/n”,addr_listt. city);printf(“%lu/n/n”, addr_listt. zip);printf(“/n/n”);畫出main函數(shù)的控制流程圖;( )4、已知c源程序如下:/*a simple mailing list example using an ar

15、ray ofstructures. */# includestdion.h#includestdlib.hdefine max 4structaddrchar name30;charstreet40;char city20;unsigned longint zip;addr_listmax;voidinit_list(void),enter(void);voiddeleteaddr(void),list(void);intmenu_select(void),find_free(void);int main(void)char choice;init_list( );/*initialize t

16、he structure array*/for(;)choice=menu_select( );switch(choice)case1:enter( );break;case 2:deleteaddr( );break;case 3:list( );break;case 4:exit(0);return 0;/*initialize the list.*/void initlist(void)register int t;for(t=0;tmax; +t)addr_listt, name0=/0;/*get a menu selection. */int menu_select(void)ch

17、ar s80. ;int c;printf(“1enter aname/n”);printf(“2delete a name/n”);printf(“3list the file/n”);printf (“4quit/”)doprintf(“/nenter yourchoice:”);gets(s);c= atoi(s);while(c1 | c4);returnc;/*input addresses into the list.*/void enter(void)intslot;char s80;slot=find_free( );if(slot=-1)printf(“/nlist full

18、”);return;printf(“entername:”);gets(addr_);printf(“enter street:”);gets(addr_listslot.street);printf(“entercity:”);gets(addr listslot.city);printf(“enter zip:”);gets(s);addr_listslot.zip=strtoul(s,/0,10);/*find an unused structure. */intfind_free(void)register intt;for(t=0; addr_listt.

19、name0&tmax;+t);if(t=max)return-1; /*no slots free*/return t;/*delete an address.*/void deleteaddr(void)register int slot;char s80;printf(“enter record#: “);gets(s);slot=atoi(s);if(slot=0 &slotmax)addr_listslot. name0=/0;/*display the list on the screen. */void list(void)register intt;for(t=0; tmax;

20、+t)if(addr_listt. name0)printf(“%s/n”, addr_listt. name);printf(“%s/n”, addr_listt. street);printf(“%s/n”,addr_listt. city);printf(“%lu/n/n”, addr_listt. zip);printf(“/n/n”);設(shè)計一組測試用例,使該程序所有函數(shù)的語句覆蓋率盡量達到100%。如果認為該程序的語句覆蓋率無法達到100%,需說明原因。( )5、針對以下c語言程序,請按要求回答問題。已知link. c源程序如下:/*link.c程序?qū)蜗蜴湵磉M行操作,首先建立一個單

21、向鏈表,然后根據(jù)用戶的選擇可以對其進行插入結(jié)點、刪除結(jié)點和鏈表反轉(zhuǎn)操作*/#includestdio.h#includestdlib.htypedef struct list_node*list_pointer; /定義鏈表指針typedef struct list_node /定義鏈表結(jié)構(gòu)int data;list_pointer link;list_node;/用到的操作函數(shù)list_pointercreate( ); /建立一個單向鏈表voidinsert(list_pointer*p_ptr, list_pointer node);/在node后加入一個新的結(jié)點void delete_

22、node(list_pointer*p_ptr,list_pointer trail, list_pointer node);/刪除前一個結(jié)點是trail的當前結(jié)點nodevoid print(list_pointer*p_ptr);/打印鏈表結(jié)點中的值list_pointer invert(list_pointer lead);/反轉(zhuǎn)鏈表int main( )list_pointer ptr=null;list_pointer node,trail;list_pointer * p=&ptr;int choose, location, i;printf(“you should createa

23、 link first:/n”);prt=create( );/*ptr 指向鏈表的第一個結(jié)點*/print(ptr);/根據(jù)用戶的不同選擇進行相應(yīng)的操作;printf(“input number 0, you can quitthe program/n”);printf(“input number 1, you can insert a newnode to link/n”);printf(“input number 2, you can delete a nodefrom the linkkn”);printf(“input number 3, you can invert thelink

24、/n”);printf(“please input you choicekn”);scanf(“ %d”, &choose)while(choose!=0) switch(choose)case 1:i=1;while(ilocation)node=node-link;i+;insert(p,node); /*p為指向ptr的指針*/print(ptr);break;case 2:printf(“you will delete anode from the link/n”);printf(“please input thelocation of the node:/n”);scanf(“%d”

25、,&location);node=ptr;if(location=1)trail=null;trail=ptr;i=1;whileilocation)trail=trail-link;i+;node=trail-link;delete_node(p, trail, node);print(ptr);break;case 3:printf(“you will invert thelink/n”);ptr=invert (ptr)print(ptr);break;default :breakreturn -1:printf(“please input youchoice/n”);scanf(“%d

26、”,&choose);return 0;/根據(jù)用戶的輸入值建立一個新的單向鏈表:list_pointer create( )int i, current, length;list_pointer p1,p2, head;printf(“please input the node number of thelink:/n”);scanf(“%d”, &length);printf(“thenumber of the link is: %d”, length);printf(“please input thedata for the link node: /n”);i=0;p1=p2=(list_

27、pointer)malloc(sizeof(list_node);head=p1;for(i=1; ilength; i+)scanf(“%d”, ¤t);p1-data=current;p2-link=p1;p2=p1;p1=(list_pointer)malloc(sizeof(list_node);p2-link=null;returnhead;畫出主函數(shù)main的控制流程圖。( )6、針對以下c語言程序,請按要求回答問題。已知link. c源程序如下:/*link.c程序?qū)蜗蜴湵磉M行操作,首先建立一個單向鏈表,然后根據(jù)用戶的選擇可以對其進行插入結(jié)點、刪除結(jié)點和鏈表反轉(zhuǎn)操作

28、*/#includestdio.h#includestdlib.htypedef struct list_node*list_pointer; /定義鏈表指針typedef struct list_node /定義鏈表結(jié)構(gòu)int data;list_pointer link;list_node;/用到的操作函數(shù)list_pointercreate( ); /建立一個單向鏈表voidinsert(list_pointer*p_ptr, list_pointer node);/在node后加入一個新的結(jié)點void delete_node(list_pointer*p_ptr,list_pointe

29、r trail, list_pointer node);/刪除前一個結(jié)點是trail的當前結(jié)點nodevoid print(list_pointer*p_ptr);/打印鏈表結(jié)點中的值list_pointer invert(list_pointer lead);/反轉(zhuǎn)鏈表int main( )list_pointer ptr=null;list_pointer node,trail;list_pointer * p=&ptr;int choose, location, i;printf(“you should createa link first:/n”);prt=create( );/*pt

30、r 指向鏈表的第一個結(jié)點*/print(ptr);/根據(jù)用戶的不同選擇進行相應(yīng)的操作;printf(“input number 0, you can quitthe program/n”);printf(“input number 1, you can insert a newnode to link/n”);printf(“input number 2, you can delete a nodefrom the linkkn”);printf(“input number 3, you can invert thelink/n”);printf(“please input you choic

31、ekn”);scanf(“ %d”, &choose)while(choose!=0) switch(choose)case 1:i=1;while(ilocation)node=node-link;i+;insert(p,node); /*p為指向ptr的指針*/print(ptr);break;case 2:printf(“you will delete anode from the link/n”);printf(“please input thelocation of the node:/n”);scanf(“%d”,&location);node=ptr;if(location=1)

32、trail=null;trail=ptr;i=1;whileilocation)trail=trail-link;i+;node=trail-link;delete_node(p, trail, node);print(ptr);break;case 3:printf(“you will invert thelink/n”);ptr=invert (ptr)print(ptr);break;default :breakreturn -1:printf(“please input youchoice/n”);scanf(“%d”,&choose);return 0;/根據(jù)用戶的輸入值建立一個新的

33、單向鏈表:list_pointer create( )int i, current, length;list_pointer p1,p2, head;printf(“please input the node number of thelink:/n”);scanf(“%d”, &length);printf(“thenumber of the link is: %d”, length);printf(“please input thedata for the link node: /n”);i=0;p1=p2=(list_pointer)malloc(sizeof(list_node);he

34、ad=p1;for(i=1; ilength; i+)scanf(“%d”, ¤t);p1-data=current;p2-link=p1;p2=p1;p1=(list_pointer)malloc(sizeof(list_node);p2-link=null;returnhead;設(shè)計一組測試用例,盡量使main函數(shù)的語句覆蓋率能達到100%。如果認為該函數(shù)的語句覆蓋率無法達到100%,需要說明原因。( )7、考慮一個根據(jù)以下簡單規(guī)格確認輸入數(shù)有效性的應(yīng)用程序:(1)輸入數(shù)由數(shù)字、符號“+”或“-”開始。(2)該數(shù)字或符號后面可接任意位數(shù)的數(shù)字。(3)這些數(shù)字可以有選擇地后接用英

35、文句號表示的小數(shù)點。(4)任何輸入數(shù),不管是否有小數(shù)點,都應(yīng)該以空格結(jié)束。請根據(jù)以上處理規(guī)則:畫出相應(yīng)的狀態(tài)轉(zhuǎn)換圖。( )8、考慮一個根據(jù)以下簡單規(guī)格確認輸入數(shù)有效性的應(yīng)用程序:(1)輸入數(shù)由數(shù)字、符號“+”或“-”開始。(2)該數(shù)字或符號后面可接任意位數(shù)的數(shù)字。(3)這些數(shù)字可以有選擇地后接用英文句號表示的小數(shù)點。(4)任何輸入數(shù),不管是否有小數(shù)點,都應(yīng)該以空格結(jié)束。請根據(jù)以上處理規(guī)則:根據(jù)狀態(tài)轉(zhuǎn)換圖,列出相應(yīng)的狀態(tài)轉(zhuǎn)換表,給出“當前狀態(tài)”、當前狀態(tài)允許的“輸入”和對應(yīng)每一個輸入下的“下一個狀態(tài)”。( )9、考慮一個根據(jù)以下簡單規(guī)格確認輸入數(shù)有效性的應(yīng)用程序:(1)輸入數(shù)由數(shù)字、符號“+”或

36、“-”開始。(2)該數(shù)字或符號后面可接任意位數(shù)的數(shù)字。(3)這些數(shù)字可以有選擇地后接用英文句號表示的小數(shù)點。(4)任何輸入數(shù),不管是否有小數(shù)點,都應(yīng)該以空格結(jié)束。請根據(jù)以上處理規(guī)則:根據(jù)狀態(tài)轉(zhuǎn)換圖和狀態(tài)轉(zhuǎn)換表,導(dǎo)出基本路徑測試的測試用例及其覆蓋的測試路徑。( )10、下圖為對4個已知數(shù)字進行排序的程序流程圖。問題:計算它的環(huán)路復(fù)雜度。( )11、下圖為對4個已知數(shù)字進行排序的程序流程圖。問題:為完成基本路徑測試,求它的一組獨立路徑。( )12、已知c源程序如下:#includestdio.h#includestring.hvoid reverse(char s)int c, i, j;for(i=

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論