下列语句序列执行后,k 的值是()。 int x = 6, y = 10, k = 5; switch (x % y) { case 0: k = x * y; case 6: k = x / y; case 12: k = x - y; default: k = x * y - x; }A.0B.5C.54D.60
下列语句序列执行后,k 的值是()。 int x = 6, y = 10, k = 5; switch (x % y) { case 0: k = x * y; case 6: k = x / y; case 12: k = x - y; default: k = x * y - x; }
A.0
B.5
C.54
D.60
参考答案和解析
54
相关考题:
阅读下列程序段,则程序的输出结果为 #include"stdio.h" #defineM(X,Y)(X)*(Y) #defineN(X,Y)(X)/(Y) main() {f int a=5,b=6,c=8,k; k=N(M(a,b),c); printf("%d\n",k);}A.3B.5C.6D.8
以下程序段的运行结果是( )。 include main() {int x=2,y=1: switch(x) {case 1: switch 以下程序段的运行结果是( )。 include<stdio.h> main() {int x=2,y=1: switch(x) {case 1: switch(y) {case 0:printf("x=2,y=1\n");break; case 1:printf("y=1\n");break; } case 2:printf("x=2\n"); } }
以下程序的运行结果是#define MIN(x,y)(x)(y)?(x):(y)main(){ int i=10,j=15,k;k=10*MIN(i,j);printf("%d\n",k);}A.10B.15C.100D.150
下列程序的运行结果是void fun(int *a, int *b){ int *k;k=a; a=b; b=k;}main(){ int a=3, b=6, *x=a, *y=b;fun(x,y);printf("%d %d", a, b);}A.6 3B.3 6C.编译出错D.0 0
阅读下列程序说明和c代码,将应填入(n)处的字句写在对应栏内。[说明]下面的程序利用递归算法计算x和y的最大公约数。[函数2.1]main ( ){ int x,y,k,t;scanf(" % d% d" , x, y);if(x>y) { t=x;x=y; y=t;}(1);while(k! =0){y=x;(2);k=y%x;}prinff( "% d" ,x); }[函数2.2说明]函数fun(char *str,char *substr的功能是计算子串sugbstr在串str中出现的次数。[函数2.2]fun(ehar * str, char * substr){ int x,y,z;(3);for(x=0;str[ x] ! = '\O';x + + )for(y=x,z=0;sabstr[z] = =str[y];(4),y+ +)if((5)= ='\0') {num + +;break;}return(num);}
阅读下列C++程序和程序说明,将应填入(n)处的字句写在对应栏内。【说明】Point是平面坐标系上的点类,Line是从Point派生出来的直线类。include <iostream.h>class Point{public:Point (int x, int y) ;Point (Point p) ;~Point();void set (double x, double y) ;void print();private:double X,Y;};Point::Point (int x, int y) //Point 构造函数{X=x; Y=y; }Point::Point ( (1) ) //Point 拷贝构造函数{X=p.X; Y=p.Y;}void Point::set (double x, double y){X=x; Y=y; }void Point::print(){cout<<' ('<<X<<","<<Y<<") "<<endl; }Point::~Point(){cout<<"Point 的析构函数被调用! "<<endl;class Line: public Point{public:Line (int x, int y, int k) ;Line (Line s) ;~Line();void set (double x, double y, double k)void print();private:double K;};(2)//Line 构造函数实现{ K=k;}(3)//Line 拷贝构造函数实现{K=s.K;}void Line::set (double x, double y, double k){ (4);K=k;}void Line::print(){cout<<" 直线经过点";(5);cout<<"斜率为: k="<<K<<endl;}Line: :~Line(){cout<<"Line 析构函数被调用! "<<endl;}void main(){Line 11 (1,1,2) ;11 .print();Linel2 (11) ;12.set (3,2,1) ;12.print();}
若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; }
有以下程序段:includedefine MAX(x,y)(x)>(y)?(x):(y)void main(){ int i,j,k; i= 有以下程序段: #include<iostream.h> #define MAX(x,y)(x)>(y)?(x):(y) void main() { int i,j,k; i=10; j=15;k=MAX(i,j)*10; cout<<k<<end1; } 程序执行后的输出结果是( )。A.15B.100C.150D.10
有以下程序段:include define MIN(x,y)(x) 有以下程序段:include<iostream.h>define MIN(x,y) (x)<(y)?(x):(y)void main(){int i,j,K;i=10;j=15;k=10*MIN (i,j);cout<<k<<endl;}程序执行后的输出结果是______。
下列程序执行之后,将输出 public class exl9 { public static void main(string[] args) { int x=3; int y=7; switch(y/x){ case 1: y*=2; break; case 2: y*=3; break; case 3: y*=4; break; default: y=0; } System.out.print(y); } }A.28B.21C.14D.0
若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; }
有以下程序#include "stdio.h"#define M(x,y) (x)*(y) #define N(x,y) (x)/(y) main(){ int a=5,b=6,c=8,k; k=N(M(a,b),c); printf("%d\n",k);} 程序的运行结果是A.3 B.5C.6 D.8
执行下面的程序后,输出的结果是 K=1 For j=1 To 4 X=X - 1: y=0 For k=1 To 4 X=X + 1: y=y + 1 Next k Next j Print X;yA.1 4B.13 4C.12 8D.20 6
若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; }
以下程序的运行结果是()。includedefine MIN(x,y) (x) 以下程序的运行结果是( )。 #include <stdio.h> #define MIN(x,y) (x)<(y)? (x):(y) main() { int i=10,j=15,k; k=10*MIN(i,j); printf("%d\n",k); }A.10B.15C.100D.150
以下程序的输出结果是( )。 union myun { struct {int x,y,z;)u; int k: }a; main { a.u.x=4;a.u.y=5;a.u.z=6; k=0; printf(%d\n",a.u.x); }A.4B.5C.6D.0
若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; } }
在下面程序运行后,输出结果为 ______。includevoid count(int x[],int n,int y 在下面程序运行后,输出结果为 ______。 #include<iostream.h> void count(int x[],int n,int y){ int k; y=0; for(k=0:k<n;k++) if(x[k]<0) y++; } void main(){ int b[]={2,1,-8,-3,7,2,4,6,0,-13}; int x; count(b,10,x); cout<<“x”<<x<<end1; }A.x=3B.x=5C.出错D.x=0
若有如下程序: main() { int k,x=0,y=0; for(k=0;k<=2;k++) switch(k) { case 0: X++; case 1: y++; case 2: X++;y++; } printf("%d,"d\n",x,y); } 则程序运行后的输出结果是( )。A.3,3B.2,2C.4,5D.2,3
下列程序的运行结果是()。void fun(int*a,int*b){int *k;k=a;a=b;b=k;}main(){int a=3,b=6,*x=a,*y=b; fun(x,y); printf("%d%d",a,b); }A.63B.36C.编译出错D.0 0
阅读下面程序,下列选项中,能够完成语句覆盖的测试用例是() if((x4)||(z7)) { k=x*y-1; j=sqrt(k); } if((x==8)(y5)) { j=x%y+2; } j=j%3;A、x=2,y=6,z=5B、x=6,y=6,z=5C、x=8,y=6,z=4D、x=8,y=5,z=5
单选题齐次坐标(x,y,z,k)表示()。A二维空间点(x,y)B二维空间点(x/k,y/k)C三维空间点(x,y,z)D三维空间点(x/k,y/k,z/k)