亚洲国产福利在线一二三观看_精品国产伦一区二区三区欲臀_国产a∨视频精品视频护士_精品八戒人妻少妇av

江蘇省高校計(jì)算機(jī)等級(jí)考試命題研究院 江蘇省高校計(jì)算機(jī)等級(jí)考試輔導(dǎo)
江蘇計(jì)算機(jī)C語言結(jié)構(gòu)體與共同體考核

江蘇省計(jì)算機(jī)等級(jí)考試輔導(dǎo)C

第三次授課資料

考點(diǎn)1:結(jié)構(gòu)體

例題:已知有結(jié)構(gòu)體定義和變量聲明如下:(2008)

struct student

{char name[20];

 int score;

 struct student *h;

}stu, *p;   int *q;

以下選項(xiàng)中錯(cuò)誤的是_________

A.p=&stu;        B.q=&stu.score;   C.scanf(“%s%d”,&stu);   D.stu.h=p;

例題:以下程序運(yùn)行時(shí)輸出結(jié)果的第一行是________,第二行是__________

#include <stdio.h>

struct s

{int x,*y;

}*p;

int d[5]={10,20,30,40,50};

struct s a[5]={100,&d[0],200,&d[1],300,&d[2],400,&d[3],500,&d[4]};

void main()

{p=a;

 printf(“%5d”,p->x++);

 printf(“%5d\n”,p->x);

 printf(“%5d”,*p->y);

 printf(“%5d\n”,*++p->y);

}

考點(diǎn)2:處理鏈表

例題:以下程序的功能是:函數(shù)struct node *insert(struct node *head, struct node *p)p指向的結(jié)點(diǎn)作為首結(jié)點(diǎn)插入head指向的鏈表中,main函數(shù)接收從鍵盤輸入的一行字符,每接收一個(gè)字符后,申請(qǐng)一個(gè)新節(jié)點(diǎn)保存該字符,并調(diào)用insert函數(shù)將新結(jié)點(diǎn)插入鏈表中,最后從表頭開始一次輸出該鏈表個(gè)結(jié)點(diǎn)成員c的值,試完善程序以達(dá)到要求的功能

#include <stdio.h>

#include <stdlib.h>

struct node

{char c;

 struct node *next;

};

void main()

{struct node *insert(struct node *head, struct node *p);

 char ch; struct node *head,*p;

 head=NULL;

 while((ch=getchar())!=’\n’)

{p=(struct node *)malloc(sizeof(struct node));

 _______________=ch;

 p->next=NULL;

 __________________;

}

p=head;

while(p!=NULL)

{printf(“%c”,p->c);

________________;

}

}

struct node *insert(struct node *head, struct node *p)

{if(head= =NULL)

head=p;

 else

 {______________________--;

  head=p;

}

 return head;

}

考點(diǎn) 3:共用體:

考點(diǎn)4:枚舉類型

例題:已知”enum ab{a,b=5,c,d}”,枚舉常量d的值是___________

考點(diǎn)5:用typedef定義類型

例題:以下結(jié)構(gòu)變量stu1的聲明形式中,錯(cuò)誤的是__________

A.typedef struct stu{char name[10];float score;} STU; STU stu1;

B.#define STU struct stu

STU {char name[10];float score;}stu1;

C.struct stu{char name[10]; float score;} stu1;

D.struct stu{char name[10];float score;} STU; STU stu1;

第十二章:文件

文件指針是很重要的一個(gè)概念,定義文件指針的格式:

考點(diǎn)1:文件打開

FILE  *文件指針名;

例如:

FILE *fp;

fp=fopen(“文件名”,”打開文件方式”);

文件的打開:

"r"(只讀)      "r+"(為讀/寫方式打開已存在的文本文件)

"w"(只寫)     。ⅲ鳎ⅲㄒ宰x/寫方式新建文本文件)

"a"(追加)     。ⅲ幔ⅲㄒ宰x/寫方式將數(shù)據(jù)追加到文件尾)

rb+”(讀寫) 為讀寫打開一個(gè)二進(jìn)制文件  “wb+”為讀寫建立一個(gè)二進(jìn)制文件

考點(diǎn)2:文件關(guān)閉

fclose(文件指針)

考點(diǎn)3:文件的讀寫函數(shù)

fputc函數(shù):將一個(gè)字符寫到磁盤文件上

fgetc函數(shù):從指定的文件讀入一個(gè)字符

fread函數(shù):用來讀一個(gè)數(shù)據(jù)塊,fwrite函數(shù):用來寫一個(gè)數(shù)據(jù)塊

fprintf函數(shù):格式化寫函數(shù),fscanf函數(shù):格式化讀函數(shù),針對(duì)的不是終端而是磁盤文件

rewind函數(shù):使位置指針重新返回文件的開頭

fseek函數(shù):改變文件的位置指針