5、下面一段代码中break语句起到()的作用。 int pointer = 1; while (pointer <= 100) { switch(pointer % 3) { case 1: pointer += 1; break; case 2: pointer += 2; break; case 3: pointer += 3; break; } pointer++; }A.结束当次循环,使控制权直接转移到控制循环的条件表达式B.从嵌套循环内部跳出最里面的循环C.终止switch语句的语句序列D.退出循环

5、下面一段代码中break语句起到()的作用。 int pointer = 1; while (pointer <= 100) { switch(pointer % 3) { case 1: pointer += 1; break; case 2: pointer += 2; break; case 3: pointer += 3; break; } pointer++; }

A.结束当次循环,使控制权直接转移到控制循环的条件表达式

B.从嵌套循环内部跳出最里面的循环

C.终止switch语句的语句序列

D.退出循环


参考答案和解析
C

相关考题:

以下程序的运行结果是 【 9 】 。main( ){ int a=2,b=7,c=5;switch(a0){ case 1:switch(b0){ case 1: printf ("@"); break;case 2: printf("!"); break;}case 0: switch(c==5){ case 0 : printf (" * "); break;case 1 : printf(" # "); break;case 2: printf(" $ "); break;}default : printf("");}printf("\n");}

有以下程序#include stdio.hmain(){ int x=1,y=0,a=0,b=0;switch(x){ case 1:switch(y){ case 0: a++; break;case 1: b++; break;}case 2: a++; b++; break;case 3: a++; b++;}printf("a=%d, b=%d\n",a,b);}程序的运行结果是A)a=1 , b=0B)a=2, b=2C)a=1, b=1D)a=2, b=1

( 18 )以下选项中与 if ( a==1 ) a=b; else a++; 语句功能不同的 switch 语句是A )switch ( a ){case : a=b ; break ;default:a++ ;}B )switch ( a==1 ){case 0 : a=b ; break ;case 1 : a++ ;}C )switch ( a ){default : a++ ; break ;case 1 : a=b ;}D )switch ( a==1 ){case 1 : a=b ; break ;case 0 : a++ ;}

论述题 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 分)

针对下列程序段,需要(52)个测试用例才可以满足语句覆盖的要求。 switch(value){ case 0: ther=30; break; case 1: ther=50; break; case 2: ther=300; case 3: ther=other/value; break; default: ther=other * value; }A.2B.3C.4D.5

下面程序的输出结果为( )。 main( ) { int a=1,b=0; switch(a) { case 1:switch (b) { case 0: printf("**0**"); break; case 1: printf("**1**"); break; } case 2: printf("**2**"); break; }}A.**0**B.**0****2**C.**0****1****2**D.有语法错误

以下程序的运行结果是( )。main()(int a=2,b=7,c=5;switch(a>0){case 1:switch(b<0){case 1:switch(");break;case 2:printf("!");break;}case 0:switch(c==5){case 0:printf("*");break;case 1:printf("");break;case 2:printf("$");break;}default:printf ("&");}printf("\n");}

针对以下C语言程序,请按要求回答问题。已知link. c源程序如下:/*link. c程序对单向链表进行操作,首先建立一个单向链表,然后根据用户的选择可以对其进行插入结点、删除结点和链表反转操作*/include<stdio. h>include<stdlib. h>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的当前结点nodevoid print(list_pointer * p_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");//建立一个单向链表prt=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 you choice\n");scanf("%d",&choose);while(choose!=0){switch(choose){case 1: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 you 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",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=1;i<length;i++){scanf("%d",&current);p1->data=current;p2->link=p1;p2=p1;p1=(list_pointer)malloc(sizeof(list_node));}p2->link=NULL;return head;}画出主函数main的控制流程图。

若a,b,c1,c2,x,y均是整型变量,正确的switch语句是______。A.switch(a+b); {case 1:y=a+b;break; case 0:y=a-b;break; }B.switch(a*a+b*b) {case 3; case 1:y=a+b;break; case 3:y=b-a;break; }C.switch a {case c1:y=a-b;break; case c2;x=a*b;break; default:x=a+b; }D.switch(a-b) {default:y=a*b;break; case 3:case 4:x=a+b;break; case 10:case11:y=a-b;break; }

设有说明:int a=1,b=0;,则执行以下语句的输出结果是______。 switch(a) {case 1: switch(b) {case 0:printf("**0**\n");break; case 1:printf("**1*\n");break; } case 2:printf("**2**\n");break; }A.**0**B.**0** **2**C.**0** **1** **2**D.switch语句中存在语法错误

已知:int a,b;下列switch语句中,( )是正确的。A.switdh (a) { case a: a + +;break; case b: b + +;break; }B.switch(a+b) { case 1:a+b;break; case 1:a-b }C.switch(a*a) { case 1,2:+ +a; case 3, 4:+ +b: }D.switch(a/10+b) { cases 5:a/5:break: default:a+b; }

下面程序的输出结果是main(){int a=15, b=21,m=0;switch(a%3){ case 0, m++; break;case 1 :m++; switch(b%2) { default: m++; case 0:m++ ;break; }}cout<<m<<end1}A.1B.2C.3D.4

有下列程序:includemain(){int x=1,y=0,a=0,b=0;switch(x){ case 1:switch(y){ case 0 有下列程序: #include <stdio.h> main() { int x=1,y=0,a=0,b=0; switch(x) { case 1: switch(y) { case 0:a++;break; case 1:b++;break; } case 2: a++;b++;break; case 3: a++;b++; } printf("a=%d,b=%d\n",a,B) ; } 程序的运行结果是( )。A.a=1,b=0B.a=2,b=2C.a=1,b=1D.a=2,b=1

下列程序的运行结果是( )。 #includestdio.h void main {int s=0,k; for(k=7;k1;k--) {switch(k) {case 1: case 4: case 7: s++: break; case 2: case 3: case 6:break; case 0: case 5: s+=2: break; }} printf("s=%d",s); }A. s=3B.s=4C.s=5D.无输出结果

下面这段代码有错误么?switch (i){case():CaseZero();break;case 1:CaseOne();break;case 2:dufault;CaseTwo();break;}

若a、b、c1、c2、x、y均是整型变量,则正确的switch语句是______。A.swich(a+b); { case 1:y=a+b;break; case 0:y=a-b;break; } case 3:y=b-a, break;B.switch(a*a+b*b) { case 3: case 1:y=a+b;break; }C.switch a { case c1:y=a-b;break; case c2:x=a*d;break; default:x=a+b; }D.switch(a-b) { default:y=a*b;break; case 3:case 4:x=a+b;break; case 10:case 11:y=a-b;break; }

若a、b、c1、c2、x、y均是整型变量,则正确的switch语句是( )。A.switch(a+b); { casel:y=a+b;break; case0:y=a-b;break; }B.switch(a*a+b*b) { case 3: case 1:y=a+b;break; case 3:y=b-a;break; }C.switch a {case c1:y=a-b;break; case c2:x=a*d;break; default:x=a+b; }D.switch(a-b) {default:y=a*b;break; case 3:case 4:x=a+b;break; case 10:case 11:y=a—b;break; }

以下选项中与iF(a==1)a=B;elsea++;语句功能不同的sWish语句是A.sWitch(a){case1:a=B;Break; deFault:a++;}B.sWitch(a==1){case0:a=B;Break; case1:a++;}C.sWitch(a){DeFault:a++;Break; case1:a=B;}D.sWitch(a==1){case1:a=B;Break; case0:a++;}

下面这段代码有错误么?switch (i){case(): 答://case()条件不能为空CaseZero();break;case 1:CaseOne();break;case 2:dufault;

若有定义语句int a,b;double x;则下列选项中没有错误的是( )。A.switch(x%2) {case O:a++;break; case 1:b++;break; default:a++;b++; }B.switch((int)x/2.0) {case O:a++;break; case 1:b++;break; default:a++;b++; }C.switch((int)x%2) {case O:a++;break; case 1:b++;break; default:a++;b++; }D.switch((int)(x)%2) {case 0.O:a++;break; case 1.0:b++;break; default:a++;b++; }

若a,b,c1,c2,x,y均是整型变量,正确的switch语句是( )。A.switch(a+b)B.switch(a*a+b*b) { case:y=a+b;break; { case 3: case:y=a-b;break; case 1:y=a+b;break; } case 3:y=b-a;break; }C.switchaD.switch(a-b) { casec1:y=a-b;break; { default:y=a*b;break; casec2:x=a*b;break; case 3:case4:x=a+b;break; default:x=a+b; case 10:case 11:y=a-b;break; } }

若有定义语句“int a,b;double X;”,则下列选项中没有错误的是( )。A.switch(X%2) { case 0:a++;break; case l:b++;break; default:a++;b++; }B.switch((int)x/2.O) { case 0:a++;break; case l:b++;break; default:a++;b++; }C.switch((int)X%2) { case 0:a++;break; case l:b++;break; default:a++;b++; }D.switch((int)(x)%2) { case 0.0:a++;break; case l.0:b++;break; default:a++;b++; }

有以下程序: include main() {int a=6,b=7,m=1;switch(a%2){ case 0:m++;break;case 1 有以下程序: #include<stdio.h> main() { int a=6,b=7,m=1; switch(a%2) { case 0:m++;break; case 1 :m++; switch(b%2) { defaut:m++; case0:m++;break; } } printf("%d\n",m); }A.1B.2C.3D.4

已知:int a,b;下列switch语句中,( )是正确的。A.switdh(a) { case a: a++;break; case b: b++:break: }B.switch(a+b) { case 1:a+b; break; case 1:a-b }C.switch(a*a) { case1,2:++a; case3,4:++b; }D.swish(a/l0+b) { cases 5:a/5;break; default:a+b: }

下列程序的输出结果是(). main( ) { int x=1,y=0,a=0,b=0; switch(x) { case 1:switch(y) { case 0:a++;break; case 1:b++;break; } case 2:a++;b++;break; case 3:a++;b++;break; } printf("a=%d,b=%d/n",a,b); }A、a=1,b=0B、a=2,b=1C、a=1,b=1D、a=2,b=2

单选题若有定义语句int a,b;double x;则下列选项中没有错误的是(  )。Aswitch(x%2){ case 0:a++;break; case 1:b++;break; default:a++;b++;}Bswitch((int)x/2.0){ case 0:a++;break; case 1:b++;break; default:a++;b++;}Cswitch((int)x%2){ case 0:a++;break; case 1:b++;break; default:a++;b++;}Dswitch((int)(x)%2){ case 0.0:a++;break; case 1.0:b++;break; default:a++;b++;}

单选题以下选项中与if(a==1) a=b;else a++;语句功能不同的switch语句是(  )。Aswitch(a){ case 1: a=b; break; default: a++;}Bswitch(a==1){ case 0: a=b; break; case 1:a++;}Cswitch(a){ default :a++; break; case 1: a=b;}Dswitch(a==1){ case 1: a=b;break; case 0: a++;}

单选题有以下程序#include main(){ int x=1,y=0,a=0,b=0; switch(x) {  case 1:      switch(y)      {       case 0:a++;break;       case 1:b++;break;      }  case 2:a++;b++;break;  case 3:a++;b++;break; } printf(a=%d,b=%d,a,b);}程序的运行结果是(  )。Aa=1,b=0Ba=2,b=2Ca=1,b=1Da=2,b=1