查看: 1972|回复: 0

国开网C语言程序设计形考任务4

[复制链接]

9162

主题

9199

帖子

24万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
241958
发表于 2020-4-23 22:28:58 | 显示全部楼层 |阅读模式
C语言程序设计形考任务4答案.doc (197.5 KB, 下载次数: 20, 售价: 3.00 元)
一、选择题(共30分,每小题2分)
题目1
假定有“struct BOOK{char title[40]; floatprice;}; struct BOOK book;”,则不正确的语句为(    )。
选择一项:
a. struct BOOK *x=malloc(book);
b. struct BOOK x={"C++Programming",27.0};
c. struct BOOK *x=malloc(sizeof(structBOOK));
d. struct BOOK *x=&book;
题目2
假定有“struct BOOK{char title[40]; floatprice;} book;”,则正确的语句为(    )。
选择一项:
a. struct BOOK x= &book;
b. struct BOOK *x=&book;
c. struct BOOK x=calloc(BOOK);
d. struct BOOK *x=BOOK;
题目3
在结构类型的定义中,不同数据成员的定义项之间采用的分隔符是(    )。
选择一项:
a. 句点
b. 冒号
c. 分号
d. 逗号
题目4
假定一个结构类型的定义为 “struct A{int a,b; doublec;};”,则该类型的长度为(    )。
选择一项:
a. 8
b. 10
c. 12
d. 16
题目5
假定一个结构类型的定义为 “struct D{int a; D* next;};”,则该类型的长度为(    )。
选择一项:
a. 4
b. 8
c. 12
d. 16
题目6
假定要访问一个结构指针变量x中的数据成员a,则表示方法为(   )。
选择一项:
a. x.a
b. x->a
c. x(a)
d. x{a}
题目7
与结构成员访问表达式x.name等价的表达式为(    )。
选择一项:
a. x->name
b. &x->name
c. (&x)->name
d. (*x)->name
题目8
假定一个链表中结点的结构类型为“struct AA{int data, structAA *next;};”,则next数据成员的类型为(    )。
选择一项:
a. struct AA
b. struct AA*
c. AA
d. int
题目9
假定一个链表的表头指针为f,结点中包含有datanext域,则向该链表的表头插入一个地址为p的结点时,应执行的操作为(    )。
选择一项:
a. p->next=f
b. p->next=ff=p
c. f=p->next
d. f->next=pf=p
题目10
标准输入设备键盘的文件流标识符是(    )。
选择一项:
a. stdin
b. stdout
c. stderr
d. stdio
题目11
表示文件结束符的符号常量为(    )。
选择一项:
a. eof
b. Eof
c. EOF
d. feof
题目12
C语言中打开一个数据文件的系统函数为(    )。
选择一项:
a. fgetc()
b. fputc()
c. fclose()
d. fopen()
题目13
从一个数据文件中读入以换行符结束的一行字符串的系统函数为(    )。
选择一项:
a. gets()
b. fgets()
c. getc()
d. fgetc()
题目14
向一个二进制文件中写入信息的函数fwrite()带有的参数个数为(    )。
选择一项:
a. 1
b. 2
c. 3
d. 4
题目15
C语言中,为只写操作打开一个文本文件的方式为(    )。
选择一项:
a. "a"
b. "r+"
c. "r"
d. "w"
二、判断题(共40分,每小题2分。叙述正确则回答,否则回答
题目16
在结构类型的定义中,其中的数据成员可以是本身类型的直接对象。
选择一项:
题目17
在结构类型的定义中,允许出现结构类型不完整的超前定义。
选择一项:
题目18
定义结构类型的变量时,不能够同时进行初始化。
选择一项:
题目19
使用一个结构类型时,必须一起使用关键字struct和类型标识符。
选择一项:
题目20
假定一个结构类型的定义为 “struct A{int a,b; A* c;};”,则该类型的长度为12
选择一项:
题目21
假定一个结构类型的定义为 “struct B{int a[5]; char*b;};”,则该类型的长度为20
选择一项:
题目22
执行calloc(n,8)函数调用时,将动态分配得到8*n个字节的存储空间。
选择一项:
题目23
执行malloc(sizeof(struct BB))函数调用时,得到的动态存储空间能够保存具有struct BB结构类型的一个对象。
选择一项:
题目24
假定要访问一个结构对象x中的由a指针成员所指向的对象,则表示方法为x.a
选择一项:
题目25
假定要访问一个结构指针p所指对象中的b指针成员所指的对象,则表示方法为p->b
选择一项:
题目26
与结构成员访问表达式(*fp).score等价的表达式是fp->score
选择一项:
题目27
C语言中,对二进制文件的所有不同打开方式共有6种。
选择一项:
题目28
C语言中的标准输入和输出设备文件都属于字符文件。
选择一项:
题目29
在一个磁盘数据文件的文件名中,文件主名和扩展名都是必须的,不可省略。
选择一项:
题目30
在数据文件打开方式字符串中,字符rwa具有确定的含义,分别代表读、写和追加方式。
选择一项:
题目31
一个磁盘数据文件的文件名由文件主名和扩展名所组成,其中间用圆点分开。
选择一项:
题目32
C语言系统中提供一个用来描述文件属性的类型标识符为FILE
选择一项:
题目33
每次只能向文本文件中写入一个字符,不能一次写入一个字符串。
选择一项:
题目34
对二进制文件进行读和写操作将使用相同的系统函数。
选择一项:
题目35
C语言中,系统函数fseek()用来移动数据文件中的文件位置指针。
选择一项:
信息文本
三、写出下列每个程序运行后的输出结果(共15分,每小题5分)
题目36
#include<stdio.h>
      struct Worker {
          char name[15];  //姓名
          int age;        //年龄
          float pay;      //工资
      };
      void main() {
          struct Worker x={"wanghua",52,4300};
          struct Worker y, *p;
          y=x; p=&x;
          printf("%s  %d  %6.2f\n",x.name,y.age,p->pay);
      }
题目37
#include<stdio.h>
      #include<string.h>
      struct Worker {
          char name[15];  //姓名
          int age;        //年龄
          float pay;      //工资
      };
      void main() {
          struct Worker x;
          char *t="liouting";
          int d=38; float f=3493;
          strcpy(x.name,t);
          x.age=d; x.pay=f;
          printf("%s  %d  %6.0f\n",x.name,x.age,x.pay);
      }
题目38
#include<stdio.h>
      struct Worker {char name[15]; int age; float pay;};
      int Less(struct Worker r1, struct Worker r2) {
          if(r1.age<r2.age) return 1; else return 0;
      }
      void main() {
          struct Worker a[4]={{"abc",25,2420},{"def",58,4638},
                       {"ghi",49,4260},{"jkl",36,3750}};
          struct Worker x=a[0];
          int i;
          for(i=1; i<4; i++)
               if(Less(x,a)) x=a;
          printf("%s  %d  %6.0f\n",x.name,x.age,x.pay);
      }
四、写出下列每个函数的功能(共15分,每小题5分)
题目39
void QA(struct Worker a[], int n) {
          int i;
          for(i=1; i<n; i++)
               scanf("%s %d%f",&a.name,&a.age,&a.pay);
      }
    假定结构类型struct Worker 的定义如下:
      struct Worker { char name[15]; int age; float pay;};
题目40
int Count(struct IntNode *f)
       {      //f为指向一个单链表的表头指针
           int c=0;
           while(f) {
                c++;
                f=f->next;
           }
           return c;
       }
    假定struct IntNode的类型定义为:
       struct IntNode {int data; IntNode* next;};
题目41
void xw1(char* fname) {
          FILE* fout=fopen(fname,"w");
          char a[20];
          printf("每个字符串长度小于20,字符串end作为结束标志\n");
          while(1) {
               scanf("%s",a);
               if(strcmp(a,"end")==0)break;
               fputs(a,fout);
               fputc('\n',fout);
          }
          fclose(fout);
      }

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

 
 
代做客服
更新报错
下载问题
充值问题
交流合作
作业代做一群:
河南电大教学考代做
作业代做二群:
电大题库吧代做二群
工作时间:
0:00-24:00
官方微信扫一扫
快速回复 返回顶部 返回列表