计算机二级

以下选项中能正确把c1定义成结构体变量的是( )。A.typedef struct { int red; int red; int green; int blue; }COLOR; COLOR c1;B.struct color c1 { int red int red; int green int blue; };C.stmctcolor { int red, int green; int blue; }c1;D.struct { int red; int green; int blue; }c1;

题目

以下选项中能正确把c1定义成结构体变量的是( )。

A.typedef struct { int red; int red; int green; int blue; }COLOR; COLOR c1;

B.struct color c1 { int red int red; int green int blue; };

C.stmctcolor { int red, int green; int blue; }c1;

D.struct { int red; int green; int blue; }c1;

如果没有搜索结果,请直接 联系老师 获取答案。
如果没有搜索结果,请直接 联系老师 获取答案。
相似问题和答案

第1题:

以下选项中不能正确把c1定义成结构体变量的是______。

A.typedef struct { int red; int green; int blue; } COLOR; COLOR cl;

B.struct color cl { int red; int green; int blue; };

C.struct color { int red; int green; int blue; } c l;

D.struct { int red; int green; int blue; } c l;


struct color cl { int red; int green; int blue; };

第2题:

9、以下选项中不能正确把c1定义成结构体变量的是______。

A.typedef struct { int red; int green; int blue; } COLOR; COLOR cl;

B.struct color { int red; int green; int blue; } c l;

C.struct color cl { int red; int green; int blue; };

D.struct { int red; int green; int blue; } c l;


B 解析:结构体类型的定义格式为: stract结构体名 成员说明列表}; 结构体变量的定义有3种形式:第一种,定义结构体类型的同时定义结构体变量,如: street结构体名{成员说明列表}变量;第二种,先定义一个结构体类型,然后使用该类型来定义结构体变量,如:strect student{成员说明列表};student变量;第三种,定义一个无名称的结构体类型的同时定义结构体变量,如:strect student{成员说明列表}变量;。

第3题:

如下选项,哪个不是定义类型名tcolor________。

A.enum tcolor{red, green, blue};

B.typedef enum color{red,green,blue} tcolor;

C.enum color {red,green,blue}; typedef enum color tcolor;

D.typedef enum {red,green,blue} tcolor;


错误

第4题:

以下选项中不能正确把cl定义成结构体变量的是()。

A.typedef struct { int red; int green; int blue; } COLOR; COLOR cl;

B.struct color cl { int red; int green; int blue; };

C.struct color { int red; int green; int blue; }cl;

D.struct { int red; int green; int blue; }c1;


B

第5题:

1、如下选项,哪个不是定义类型名tcolor________。

A.enum tcolor{red, green, blue};

B.typedef enum color{red,green,blue} tcolor;

C.enum color {red,green,blue}; typedef enum color tcolor;

D.typedef enum {red,green,blue} tcolor;


enum tcolor{red, green, blue};

第6题:

阅读以下说明和 Java 代码,填补代码中的空缺,将解答填入答题纸的对应栏内。 【说明】 设计 RGB 方式表示颜色的调色板,进行绘图。其类图如图 6-1 所示。该程序的 Java代码附后。图6-1 类图

【Java 代码】 //颜色类 class MyColor { private int red ,green, blue; public MyColor( ) { red = o; green = 0; blue = 0; } public MyColor(int red ,int green ,int blue) { this.red = red; this.green = green; this.blue = blue; } //其他方法略 public String toString( ) { return "Red: " + red + "\tGreen: " + green + "\tBlue " + blue; } } //调色板类 class Palette { public int number; / /颜色数 private (1)palette; //颜色表 public Palette( ) { number = 256; palette = new MyColor[number); } public Palette(MyColor[] palette ,int number) { (2)= number; (3)= palette; } //其他方法略 public String toString( ) { String str = ""; for (int i = 0; i < number; i++) { str +=i+ " : " + palette[i] + "\n"; } return str; } //绘图类 class Drawing { public (4) int COLORNUMBER = 16; public static void main(String[] args) { Palette palette; int red ,green ,blue; MyColor[] color = new MyColor[COLORNUMBER]; for (int i = 0; i < COLORNUMBER; i++) { red = (int) (Math.random( ) * 256); green = (int) (Math.random( ) * 256); blue = (int) (Math.random( ) * 256); color [i] = (5) (red ,green ,blue); } palette = new Palette(color ,COLORNUMBER); System.out.println(palette); } }


正确答案:(1) MyColor[]
(2) this.number
(3) this.palette
(4) static final
(5) new MyColor

第7题:

若有以下语句:typedef struct S{int 9;char h;}T;以下叙述中正确的是( )。

A.可用s定义结构体变量

B.可用T定义结构体变量

C.S是struct类型的变量

D.T是struct S类型的变量


正确答案:B
本题考查typledef重新声明一种结构体类型,那么T为结构体类型,而不是结构体变量,所以B选项正确。

第8题:

以下选项中不能正确把c1定义成结构体变量的是

A.typedef struct { int red; int green;; int blue; }COLOR; COLOR cl;

B.struct color cl { int red; int green; int blue; };

C.struet color { int red; int green; int blue; }c1;

D.struct { int red; int green; int blue; }cl;


正确答案:B
解析:结构体类型的定义格式为:
  stract结构体名
  成员说明列表};
  结构体变量的定义有3种形式:第一种,定义结构体类型的同时定义结构体变量,如: street结构体名{成员说明列表}变量;第二种,先定义一个结构体类型,然后使用该类型来定义结构体变量,如:strect student{成员说明列表};student变量;第三种,定义一个无名称的结构体类型的同时定义结构体变量,如:strect student{成员说明列表}变量;。

第9题:

以下选项中不能正确把c1定义成结构体变量的是

A.typedef struct {int red: int green: int blue; } COLOR; COLOR c1;

B.struct color c1 {int red int green: int blue; };

C.struct color {int red , int green : int blue : )cl;

D.struct {int red; int green; int blue } c1 ;


正确答案:B
解析:本题考核的知识点是结构体类型定义。结构体类型的定义格式为:strcut结构体名{成虽说明列表};结构体变量的定义有3种形式:第一种,定义结构体型的同时定义结构体变量,如:strcut结构体名{成员说明列表}变量;选项C属于这种情况,故选项C正确:第二种,先定义一个结构体类型,然后使用该类型来定义结构体变量,如:strcutstudent{成员说明列表}:student变量;选项A属于这种情况,故选项A正确;第三种,定义一个无名称的结构体类型的同时定义结构体变量,如:strcutstudent{成员说明列表}变量;选项D属于这种情况,故选项D正确.所以,4个选项中选项B符合题意。