网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

论述题 3 :针对以下 C 语言程序,请按要求回答问题( 18 分)

已知 link.c 源程序如下:

/*link.c 程序对单向链表进行操作 , 首先建立一个单向链表 , 然后根据用户的选择可以对其进行插入节点 、

删除节点和链表反转操作 */

#include

#include

typedef struct list_node *list_pointer; // 定义链表指针

typedef struct list_node{ // 定义链表结构

int data;

list_pointer link;

}list_node;

// 用到的操作函数:

list_pointer create(); // 建立一个单向链表

void insert(list_pointer *p_ptr, list_pointer node); // 在 node 后加入一个新的节点

void delete_node(list_pointer *p_ptr, list_pointer trail, list_pointer node);

// 删除前一个节点是 trail 的当前节点 node

void print(list_pointer ptr); // 打印链表节点中的值

list_pointer invert(list_pointer lead); // 反转链表

int main()

{

list_pointer ptr=NULL;

list_pointer node, trail;

list_pointer *p = &ptr;

int choose, location, i;

printf("you should create a link first:\n");

// 建立一个单向链表:

ptr=create(); /* ptr 指向链表的第一个节点 */

print(ptr);

// 根据用户的不同选择进行相应的操作:

printf("input number 0, you can quit the program\n");

printf("input number 1, you can insert a new node to link\n");

printf("input number 2, you can delete a node from the link\n");

printf("input number 3, you can invert the link\n");

printf("please input your choice\n");

scanf("%d", &choose);

while(choose!=0){

switch(choose){

case 1:

printf("you will insert a node to the link\n");

printf("please input the location of the node:\n");

scanf("%d", &location);

node = ptr;

i = 1;

while(i<location){

node = node->link;

i++;

}

insert(p, node); /* p 为指向 ptr 的指针 */

print(ptr);

break;

case 2:

printf("you will delete a node from the link\n");

printf("please input the location of the node:\n");

scanf("%d", &location);

node = ptr;

if(location ==1)

trail = NULL;

trail = ptr;

i = 1;

while(i<location){

trail = trail->link;

i++;

}

node = trail->link;

delete_node(p, trail, node);

print(ptr);

break;

case 3:

printf("you will invert the link\n");

ptr = invert(ptr);

print(ptr);

break;

default:

break;

return -1;

}

printf("please input your choice\n");

scanf("%d", &choose);

}

return 0;

}

// 根据用户的输入数值建立一个新的单向链表:

list_pointer create()

{

int i, current, length;

list_pointer p1, p2, head;

printf("please input the node number of the link:\n");

scanf("%d", &length);

printf("the number of the link is : %d\n", length);

printf("please input the data for the link node:\n");

i =0;

p1= p2= (list_pointer) malloc(sizeof(list_node));

head = p1;

for(i = 0; i

scanf("%d", ¤ t);

p1->data = current;

p2->link = p1;

p2 = p1;

p1 = (list_pointer) malloc(sizeof(list_node));

}

p2->link = NULL;

return head;

}

……

( 1 )画出主函数 main 的控制流程图。( 10 分)

( 2 ) 设计一组测试用例 , 尽量使 main 函数的语句覆盖率能达到 100% 。 如果认为该函数的语句覆盖率无法达到 100% ,需说明原因。( 8 分)


参考答案

更多 “ 论述题 3 :针对以下 C 语言程序,请按要求回答问题( 18 分)已知 link.c 源程序如下:/*link.c 程序对单向链表进行操作 , 首先建立一个单向链表 , 然后根据用户的选择可以对其进行插入节点 、删除节点和链表反转操作 */#include#includetypedef struct list_node *list_pointer; // 定义链表指针typedef struct list_node{ // 定义链表结构int data;list_pointer link;}list_node;// 用到的操作函数:list_pointer create(); // 建立一个单向链表void insert(list_pointer *p_ptr, list_pointer node); // 在 node 后加入一个新的节点void delete_node(list_pointer *p_ptr, list_pointer trail, list_pointer node);// 删除前一个节点是 trail 的当前节点 nodevoid print(list_pointer ptr); // 打印链表节点中的值list_pointer invert(list_pointer lead); // 反转链表int main(){list_pointer ptr=NULL;list_pointer node, trail;list_pointer *p = ptr;int choose, location, i;printf("you should create a link first:\n");// 建立一个单向链表:ptr=create(); /* ptr 指向链表的第一个节点 */print(ptr);// 根据用户的不同选择进行相应的操作:printf("input number 0, you can quit the program\n");printf("input number 1, you can insert a new node to link\n");printf("input number 2, you can delete a node from the link\n");printf("input number 3, you can invert the link\n");printf("please input your choice\n");scanf("%d", choose);while(choose!=0){switch(choose){case 1:printf("you will insert a node to the link\n");printf("please input the location of the node:\n");scanf("%d", location);node = ptr;i = 1;while(ilocation){node = node-link;i++;}insert(p, node); /* p 为指向 ptr 的指针 */print(ptr);break;case 2:printf("you will delete a node from the link\n");printf("please input the location of the node:\n");scanf("%d", location);node = ptr;if(location ==1)trail = NULL;trail = ptr;i = 1;while(ilocation){trail = trail-link;i++;}node = trail-link;delete_node(p, trail, node);print(ptr);break;case 3:printf("you will invert the link\n");ptr = invert(ptr);print(ptr);break;default:break;return -1;}printf("please input your choice\n");scanf("%d", choose);}return 0;}// 根据用户的输入数值建立一个新的单向链表:list_pointer create(){int i, current, length;list_pointer p1, p2, head;printf("please input the node number of the link:\n");scanf("%d", length);printf("the number of the link is : %d\n", length);printf("please input the data for the link node:\n");i =0;p1= p2= (list_pointer) malloc(sizeof(list_node));head = p1;for(i = 0; iscanf("%d", ¤ t);p1-data = current;p2-link = p1;p2 = p1;p1 = (list_pointer) malloc(sizeof(list_node));}p2-link = NULL;return head;}……( 1 )画出主函数 main 的控制流程图。( 10 分)( 2 ) 设计一组测试用例 , 尽量使 main 函数的语句覆盖率能达到 100% 。 如果认为该函数的语句覆盖率无法达到 100% ,需说明原因。( 8 分) ” 相关考题
考题 论述题3:针对以下C语言程序,请按要求回答问题下面是一个简单的C语言程序:(1)画出该函数的程序流程图。(2)设计测试用例,分别使函数的各种逻辑覆盖率尽量达到100%。如果认为该函数的某种逻辑覆盖率无法达到100%,需要说明原因。(3)设计特殊的测试用例,说明各种逻辑覆盖之间的关系。

考题 论述题1:以下是某应用程序的规格描述,请按要求回答问题程序规则:实现某城市的电话号码,该电话号码由三部分组成。它的说明如下:区号空白或3位数字;前缀非“0”或“1”开头的3位数字;后缀4位数字。(1)请分析该程序的规则说明和被测程序的功能(2)采用等价类划分方法设计测试用例。

考题 论述题3:针对以下C语言程序,请按要求回答问题下面是一个程序段(C语言),试设计基本路径测试的测试用例,设计出的测试用例要保证每一个基本独立路径至少要执行一次。函数说明:当i flag=0;返回i count+100当i flag=l;返回i count*10否则 返回 i count*20输入参数:int i count int i flag输出参数:int i retum程序代码如下:(1)画出该函数的控制流程图。(2)采用基本路径测试法设计一组测试用例,保证每个基本独立路径都至少执行一次。

考题 针对一下C语言程序,请按要求回答问题。 已知weekday. c源程序如下: include include 针对一下C语言程序,请按要求回答问题。已知weekday. c源程序如下:include<stidio. h>include<conio. h>/ *主函数* /Int main(){Char letter;Printf("please input the first letter,"Y'to exit!\n");While((letter=getch())!="Y")//当输入字母为Y时结束{Switch(letter){Case'S':Printf("%c\n",letter);Printf("please input second letter\n");//输入第二个字母If((letter=getch())=='a')Printf("Saturday\n");Else if(letter=='u')Printf("Sunday\n");Else printf('data error\n);Break;Case'F':Printf("fridaykn");Break;Case 'M':Printf("mondayha");Break;Case 'T':Printf("%c\n",letter);Printf("please input second letter\a");//输入第二个字母If((letter=getch())=='u')Printf("Tuesday\n"):Else if(letter=='h')Printf("Thursday\n");Break;Case 'W':Printf("Wednesday\n");}}Return 0;}(1) 画出主函数main的控制流程图;(2) 设计一组测试用例,使main函数的语句覆盖率尽量达到100%;(3) Main函数的语句覆盖率能否达到100%?如果认为无法达到,需说明原因。

考题 以下对C语言的描述中,正确的是______。A.C语言源程序中可以有重名的函数B.C语言源程序中要求每行只能书写一条语句C.注释可以出现在C语言源程序中的任何位置D.最小的C语言源程序中没有任何内容

考题 阅读下列C程序,回答问题1至问题3,将解答填入答题纸的对应栏内。【说明】逻辑覆盖法是设计白盒测试用例的主要方法之一,它是通过对程序逻辑结构的遍历实现程序的覆盖。针对以下由C 语言编写的程序,按要求回答问题。 问题1:(6分) 请针对上述C程序,给出满足100%DC(判定覆盖)所需的逻辑条件。 问题2:(7分)请画出上述程序的控制流图,并计算其控制流图的环路复杂度V(G)。 问题3:(3分)请给出【问题2】中控制流图的线性无关路径。

考题 【说明】逻辑覆盖法是设计白盒测试用例的主要方法之一,它是通过对程序逻辑结构的遍历实现程序的覆盖。针对以下由C 语言编写的程序,按要求回答问题。 问题1:(4分)请给出满足100%DC(判定覆盖)所需的逻辑条件。 问题2:(8分)请画出上述程序的控制流图,并计算其控制流图的环路复杂度V(G)。问题3:(3分)请给出【问题2】中控制流图的线性无关路径。

考题 阅读下列Java程序,回答问题1至问题3,将解答填入答题纸的对应栏内。【说明】逻辑覆盖法是设计白盒测试用例的主要方法之一,它是通过对程序逻辑结构的遍历实现程序的覆盖。针对以下由Java语言编写的程序,按要求回答问题。 问题1:(2分) 请简述基本路径测试法的概念。 问题2:(8分)请画出上述程序的控制流图,并计算其控制流图的环路复杂度V(G)。 问题3:(3分)请给出【问题2】中控制流图的线性无关路径。

考题 阅读下列程序,回答问题1至问题3,将解答填入答题纸的对应栏内。【说明】逻辑覆盖法是设计白盒测试用例的主要方法之一,它是通过对程序逻辑结构的遍历实现程序的覆盖。针对以下由C 语言编写的程序,按要求回答问题。 问题1:(5分)请给出满足100%DC(判定覆盖)所需的逻辑条件。 问题2:(7分)请画出上述程序的控制流图,并计算其控制流图的环路复杂度V(G)。 问题3:(3分)请给出【问题2】中控制流图的线性无关路径。

考题 阅读下列程序,回答问题1至问题3,将解答填入答题纸的对应栏内。【说明】逻辑覆盖法是设计白盒测试用例的主要方法之一,它是通过对程序逻辑结构的遍历实现程序的覆盖。针对以下由C 语言编写的程序,按要求回答问题。 main( ){int i,n; //1for(i=1;i