chap10.ppt

Size: px
Start display at page:

Download "chap10.ppt"

Transcription

1 第十章 结构体与共用体 10.1 结构体 10.2 链表 10.3 共用体 10.4 枚举类型 10.5 用 typedef 定义类型

2 10.1 结构体 数组, 相同类型的数据集合 foxpro 中, 记录 : 字段有序集 ( 各字段类型可不相同 ) 换句话说, 将不同类型的数据组合成一个整体 结构体 (structure): 一种归在同一名之下的各种变量的组合称结构体的各个成员 一 定义 : 格式 1: struct 结构体名 { 类型 变量名 ; 类型 变量名 ; 称成员列表 ; 结果 : 产生一个结构体的具体类型 struct 结构体名例 struct ww { int a; char c; ; 则该类型为 struct ww.

3 定义结构体变量 : 类型变量名表例 struct ww y; 定义一个结构体变量 y, y 的具体类型为 struct ww 格式 2: 定义类型的同时定义变量 struct 结构体名 { 成员列表 结构体变量表 ; 例 struct ww { int a; char c; y; 或 struct { int a; char c; y; 说明 : ⑴ 格式 2 时, 结构体名可以省掉但不能再定义变量 ⑵ P 262 ⑶ 结构体长度 = 其各成员长度之和上例 struct ww 长度 = 3 B ⑷ 成员名可与程序中的变量名同名, 互不干扰.

4 例 欲定义如下结构 : 学号姓名性别身高出生日期 int char char float struct date num name[20] sex height birthday m-male f-female 结构体 int int int year month day 需先定义被包含的结构体 struct date { int year; int month; int day;; struct student { int num; char name[20]; char sex; /* */ float height; struct date birthday; stu, ss[3]; /* 定义变量时才分配存储空间 */ 数组元素及其成员关系 P 265, 存储方式 P 266 二 使用.

5 使用格式 : 结构体变量名 成员名结构体成员运算符 ⒉ 成员与普通变量一样进行赋值 存取等运算 例 scanf( %d, &stu num); ⒊ 结构体中又有结构体的, 返回时必须用 一级一级向下查找, 直到最低级为止 例 scanf( %d, &stu birthday year); 三 初始化 struct 结构体名 { 成员列表 变量名 ={ 初始值 ; 例 struct ww { int a; char c; y={ 5, t ; 接前面例 struct student a[2] ={{12, LiMing, m, 1.75, {1982, 3, 2, {23, LiuHua, f, 1.65, {1984,7,17;.

6 例 输入输出一学生情况 #define XH stu.num #define XM stu.name #define XB stu.sex #define SG stu.height #define L stu.birthday.year #define Y stu.birthday.month #define R stu.birthday.day main( ) { struct date { int year; int month; int day;; struct student { int num; char name[20]; char sex; float height; struct date birthday; stu; /* 定义变量时才分配存储空间 */ printf(" 输入一学生的学号姓名性别身高出生日期 ( 年. 月. 日 ):\n"); scanf("%d%s%*c%c%f%d.%d.%d", &XH, XM, &XB, &SG, &L, &Y, &R); printf(" 输出该学生信息 : \n"); printf(" 学号姓名性别身高出生日期 ( 年. 月. 日 )\n"); printf("%-5d%-16s%-4c%-5.2f%4d.%2d.%2d\n", XH, XM, XB, SG, L, Y, R);.

7 四 结构体与指针 ⒈ 指针变量定义方式 : 与以前方式相同例 struct student s, stu[3], *p=&s, *q=stu; q+=1; /* 该 1 为一个元素长度 33B */ ⒉ 使用方式 : ⑴ 使用成员方式有三种 : 1 结构体变量 成员 2 (* 指针变量 ) 成员 3 指针变量 -> 成员 ⑵ 取内容 : 为了简化和直观 22 LiHua F s.num (*p).num p->num s.name (*p).name p->name s.birthday.year (*p).birthday.year p->birthday.year stu[1].num (*(q+1)).num (q+1)->num stu[1].name (*(q+1)).name (q+1)->name stu[1]. birthday.year (*(q+1)).birthday.year (q+1)-> birthday.year (q+1)->birthday->year. p B 20B 1B 4B 2B 2B 2B stu q stu[0] stu[1] stu[2]

8 ⑶ 取地址 : &s.num &(*p).num &p->num s.name (*p).name p->name &s.birthday.year &(*p).birthday.year &p->birthday.year 22 2B LiHua 20B F 1B B B 07 2B 07 2B stu[0] stu[1] stu[2] &stu[1].num &(*(q+1)).num &(q+1)->num stu[1].name (*(q+1)).name (q+1)->name &stu[1]. birthday.year &(*(q+1)). birthday.year &(q+1)-> birthday.year p stu q 例 显示时 分 秒的软件延时.

9 struct tm { int hours; int minutes; int seconds; ; main( ) { struct tm f, time={0, 0, 0; int i, n; printf( \n 请输入延时时间 ( 时 : 分 : 秒 ): ); scanf( %d:%d:%d, &f.hours, &f.minutes, &f.seconds); n=f.hours*60*60+f.minutes*60+f.seconds; for(i=0; i<n; i++) update(&time), display(time); update( struct tm *f ) { f->seconds++; if(f->seconds==60) f->seconds=0, f->minutes++; if(f->minutes==60) f->minutes=0, f->hours++; if(f->hours==24) f->hours=0; delay( ); display( struct tm f ) { printf("%d:%d:%d\t", f.hours, f.minutes, f.seconds); delay( ) { sleep(1);.

10 或 : 采用系统日期和时间库函数 ( 头文件 time.h), time.h 中定义了 time_t 类型, 作为一个长整型数来代表系统的日期和时间 返回当前系统日历时间 ( 调用时可使用空指针 ): time_t time( time_t *time ) 返回以秒为单位的 t1 t2 之间的时间差 : double difftime( time_t t1, time_t t2 ) #include <time.h> #define NULL 0 /* #include <stdio.h> P 256 */ struct t {int hours; int minutes; int seconds;; main( ) { time_t start; struct t t, ti={0,0,0; int i, n; printf( \n 请输入延时时间 ( 时 : 分 : 秒 ): ); scanf("%d:%d:%d", &t.hours, &t.minutes, &t.seconds); n=t.hours*60*60+t.minutes*60+t.seconds; start=time(null); for(i=0; i<n; i++) update(&ti, &start), display(&ti);

11 update(struct t *f, time_t *s) { f->seconds++; if(f->seconds==60) f->seconds=0, f->minutes++; if(f->minutes==60) f->minutes=0, f->hours++; if(f->hours==24) f->hours=0; delay(s); display(struct t *f) { printf("%d:%d:%d\t",f->hours,f->minutes,f->seconds); delay(time_t *star) { time_t end; while(2) { end=time(null); if (difftime(end, *star)==1) { *star=time(null); break;

12 注意 :1 结构体变量间可相互赋值 main( ) { struct tt { float a; float b; ; struct ss { int i; char c; struct tt f; x={12, 'a', {34.124, , *f=&x, y, z; y=*f; z=x; printf("y: %d, %c, %g, %g\n", y.i, y.c, y.f.a, y.f.b); printf("z: %d, %c, %g, %g\n", z.i, z.c, z.f.a, z.f.b); 2 结构体变量间不能直接比较大小, 必须通过其相关成员进行比较 if ( y==z ) if ( y==*f ).

13 10.2 链表 数组 : 长度在定义时必须指定, 系统分配固定 连续 相邻的存储空间 变长数组 (malloc( ) calloc( ) 申请 ): 根据申请字节数分配连续 相邻的存储空间 缺点 : 存储空间申请和分配的, 是连续 相邻的存储空间 不能根据使用情况灵活地分配 释放局部空间, 有效地利用内存中的零碎空间 解决链表 : 把相同结构的数据通过指针联系起来, 灵活动态地以一个结构数据为单位分配使用存储空间 ( 需要时才分配 ), 且可由不连续的存储空间构成 头指针 数据可以为 C 语言的所有类型 称为结点 head 数据 1 数据 2 数据 3 数据 NULL 空指针.

14 结点构成 : 必须采用结构体, 例 struct node { int num; char name[20]; char sex; struct node *next; ; 结构体中再包含一个自身类型的指针成员, 指向下一结点 空指针 :P 256~257 头指针 : 仅只是一个指向结构体的指针例 struct node *head; head= 数据 1 地址 ; 数据 1~n 的存储空间是动态的,malloc( ) calloc( ) 申请分配空间,free( ) 释放空间 head 例 建立并输出学生链表, 且能根据学号删除结点 NULL 分析 :. 先产生头指针 : struct node *head=null;. 然后申请结点 1 空间, 并把结点 1 链到头指针上

15 struct node *head=null, *p, *q; int i; if((p=(struct node *)malloc(sizeof(struct node)))==null) { printf( 存储空间分配失败.\n ); head p 2002 exit(0); /* P 313 */ head 2002 数据 1 NULL NULL scanf("%d%s%*c%c%*c",&p->num,p->name,&p->sex); head=p; p->next=null;. 接下来申请结点 2~n 空间, 并把它们链结到链表中 for(i=2, q=p; i<=n; i++) {if((p=(struct node *)malloc(sizeof(struct node)))==null) printf( 存储空间分配失败.\n ), exit(0); scanf("%d%s%*c%c%*c",&p->num,p->name,&p->sex); q->next=p; head q 2002 p 1058 q=p; 2002 数据 1 数据 2 p->next=null; 1058 NULL.

16 搜索链表 p=head; while (p!=null) { ; p=p->next; 删除链表的某一结点 ( 如根据学号删除 ) printf( 请输入欲删除学生的学号 : ); scanf("%d%*c", &num); p=q=head; while( p!=null) { if( p->num==num) { q->next=p->next; free(p); p=q; q=p; p=p->next; head 2002 q p 数据 1 数据 2 数据 3 数据 NULL.

17 插入结点 : 插入在 p 指针指向的结点之前 f 指向一个刚申请到的节点空间 ; f->next=q->next; q->next=f; 或 f->next=p; q->next=f; q f 2 数据 i 数据 j 数据 k next next next 数据 l next p 1.

18 程序 1: #include <process.h> #include <stdlib.h> #define NULL 0 ( 或 #include <stdio.h> ) struct node { int num; char name[20]; char sex; struct node *next; ; struct node *input( struct node *),*delete( struct node *); void output( struct node *); main( ) { char choice, menu( ); struct node *head=null; do { choice=menu( ); /* 根据菜单选择, 调用相应模块 */ switch(choice) { case 1 : head=input(head); break; case 2 : output(head); break; case 3 : head=delete(head); break; case 0 : break; default : printf( 选择号不对, 请重选.\n ); while(choice!= 0 );.

19 /* 显示菜单, 并接受选择号 */ char menu( ) { char ch; printf( \n ); printf( 1.input \n ); printf( 2.output \n ); printf( 3.delete \n ); printf( 0.exit \n ); printf( 请输入你的选择 (0-3): ); scanf("%c%*c", &ch); return ch;.

20 struct node * input( struct node *h) /* 增加链表结点 */ { struct node *p=h, *q; char ch= Y ; /* 对应程序 1 */ while ( p!=null) q=p, p=p->next; while(ch== Y ch== y ) /* 循环控制 */ { p=(struct node *)malloc( sizeof(struct node)); if( p==null) { printf( 存储空间分配失败.\n ); return; printf( 请输入一学生的学号姓名性别 ( 之间ㄩ分隔 ):\n"); scanf("%d%s%*c%c%*c", &p->num, p->name, &p->sex); if(h==null) h=q=p; else q->next=p; q=p; p->next=null; printf(" 继续输入其它学生情况吗 (Y/N)? "); scanf("%c%*c",&ch); return h;.

21 /* 输出链表 */ void output( struct node *head) { struct node *p=head; printf( 学号姓名性别 \n ); if(h==null) { printf( 链表现在是空表 \n"); return; while (p!=null) { printf("%-4d%-20s%c\n", p->num, p->name, p->sex); p=p->next;.

22 struct node *delete( struct node *h ) /* 删除链表结点 */ { int num; char ch= Y ; struct node *p, *q; while(ch== Y ch== y ) /* 对应程序 1 */ { printf( 输入欲删学生学号 : ); scanf( %d%*c, &num); if(h==null) return NULL; q=h; /* 先判断第一个结点 */ if(q->num==num) p=q, q=q->next, free(p), h=q; p=q->next; while( p!=null) { if( p->num==num) { q->next=p->next; free(p); p=q; q=p; p=p->next; printf(" 继续删除其它学生吗 (Y/N)? "); scanf("%c%*c", &ch); return h;. h 2002 q h 数据 1 数据 q p p 2002 数据 q 1058 数据 数据 3 数据 NULL

23 或 struct node *delete( struct node *h ) /* 删除链表结点 */ { int num, s=0; char ch= Y ; struct node *p, *q; while(ch== Y ch== y ) /* 对应程序 1 */ { if(h==null) {printf(" 链表现在是空表 \n");return NULL; printf( 输入欲删学生学号 : ); scanf( %d%*c, &num); q=h; /* 先判断第一个结点 */ if(q->num==num) p=q,q=q->next,free(p),h=q,s++; p=q->next; while( p!=null) { if( p->num==num) { q->next=p->next; free(p); p=q; s++; q=p; p=p->next; if(s==0) printf( 没有满足条件的学生 \n"); else printf( 删除了 %d 个学生 ",s); s=0; printf(" 继续删除其它学生吗 (Y/N)? "); scanf("%c%*c", &ch); return h;.

24 或者程序 2 : #include <process.h> #include <stdlib.h> #define NULL 0 ( 或 #include <stdio.h> ) struct node { int num; char name[20]; char sex; struct node *next; ; void input( struct node **), output( struct node *), delete( struct node **); main( ) { char choice, menu( ); struct node *head=null; do { choice=menu( ); /* 根据菜单选择, 调用相应模块 */ switch(choice) /* &head 解释见 29 页 */ { case 1 : input(&head); break; case 2 : output(head); break; case 3 : delete(&head); break; case 0 : break; default : printf( 选择号不对, 请重选.\n"); while(choice!='0');.

25 /* 显示菜单, 并接受选择号 */ char menu( ) { char ch; printf( \n ); printf( 1.input \n ); printf( 2.output \n ); printf( 3.delete \n ); printf( 0.exit \n ); printf( 请输入你的选择 (0-3): ); scanf("%c%*c", &ch); return ch;.

26 void input( struct node **h) /* 增加链表结点 */ { struct node *p=*h, *q; char ch= Y ; /* 对应程序 2 */ while ( p!=null) q=p, p=p->next; while(ch== Y ch== y ) { p=(struct node *)malloc( sizeof(struct node)); if( p==null) { printf( 存储空间分配失败.\n ); return; printf( 请输入一学生的学号姓名性别 ( 之间ㄩ分隔 ):\n"); scanf("%d%s%*c%c%*c", &p->num, p->name, &p->sex); if(*h==null) *h=q=p; else q->next=p; q=p; p->next=null; printf(" 继续输入其它学生情况吗 (Y/N)? "); scanf("%c%*c",&ch);.

27 /* 输出链表 */ void output( struct node *head) { struct node *p=head; printf( 学号姓名性别 \n ); if(h==null) { printf( 链表现在是空表 \n"); return; while (p!=null) { printf("%-4d%-20s%c\n", p->num, p->name, p->sex); p=p->next;.

28 void delete( struct node **h ) /* 删除链表结点 */ { int num; char ch= Y ; struct node *p, *q; while(ch== Y ch== y ) /* 对应程序 2 */ { if(*h==null) {printf( 这是一个空链表.\n ); return NULL; printf( 输入欲删学生学号 : ); scanf( %d%*c, &num); q=*h; /* 先判断第一个结点 */ if(q->num==num) p=q, q=q->next, free(p), *h=q;. p=q->next; while( p!=null) { if( p->num==num) { q->next=p->next; free(p); p=q; q=p; p=p->next; printf(" 继续删除其它学生吗 (Y/N)? "); scanf("%c%*c", &ch); h 2002 q h 数据 1 数据 q p p 2002 数据 q 1058 数据 数据 3 数据 NULL

29 1. 实参为 &head 和 head 的不同 2. 可通过赋地址传递方法获得变化 返回指针值后的地址值.

30 1. main( ) { struct node *head=null ; /* 赋地值传递, 使实参形参指向共同的存储单元 */ input( &head ); output( head ); input (struct node **h) { output (struct node *h ) { main( ) { struct node *head=null ; input(&head ); output( head ); input (struct node **h) { output (struct node *h ) { 实参 &head 形参 h &head head NULL 通过 h 改变所指空间的值, 会影响 &head 指向的空间值 实参 head 2256 形参 h 2256 实参 head 2256 形参 h 1042 f 值的改变不会影响 head 的数值. 改变 f 值后

31 2. main( ) { struct node *head=null ; /* 赋地值传递, 使实参形参指向共同的存储单元 */ input( &head ); output( head ); input (struct node **h) { output (struct node *f ) { 实参 &head head NULL 形参 h &head 通过 h 改变所指空间的值, 会影响 &head 指向的空间值 main( ) { struct node *head; struct node *input( ); head = input( head ); output( head ); struct node *input ( head) struct node *head ; { return head output (struct node *f ) {

32 10.3 共用体 共用体 : 使不同类型的变量共用同一段内存单元 一 定义 ( 方法与结构体类似 ): 格式 : union 共用体名 { 成员列表 变量名 ; 例 union data { int i; char c; float f; a; 1 使用 i 成员时, 占用 2B 2 使用 c 成员时, 占用 1B 3 使用 f 成员时, 占用 4B a 变量所占长度 = 字节最长的成员长度

33 注意 : 各成员公用一段内存单元 : 共用体变量地址和各成员地址都是同一个地址 每一时刻只能存放一个成员 每一时刻只有一个成员起作用 二 使用 : 共用体变量 成员名例 a.c 例 main( ) /* 各成员公用一段内存单元 */ { union { char c; int i; h; h.i=0x39; /*(39) 16 =(48+9) 10, 而 0 =48 */ printf( %c\n, h.c); 结果 :9 注意 :1 共用体变量间的赋值及参数传递情况

34 union ss { int i; char c; ; main( ) { union ss x={49, *f=&x, y, z; void ff( union ss ), tt( union ss * ); y=*f; z=x; printf(" y: %d, %c\n", y.i, y.c); printf(" z: %d, %c\n", z.i, z.c); ff( z ); tt( f ); void ff( union ss a ) { printf(" a: %d, %c\n", a.i, a.c ); void tt( union ss *p ) { union ss h=*p; printf("*p: %d, %c\n", *p, *p); printf(" h: %d, %c\n", h.i, h.c);.

35 2 共用体变量间不能直接比较大小, 必须通过其相关成员进行比较 union ss { int i; char c; x={49, *f=&x, y, z; y=*f; z=x; f if ( y==z ) if ( y==*f ) 例 main( ) { union data { int i; int j; long f; x; x.i=2; x.j=6; x.f=x.i*x.j; printf("x.i=%d, x.j=%d\n", x.i, x.j); 结果 :x.i=36, x.j=36. j i

36 10.4 枚举类型 枚举 : 一个被命名为整型常量的集合 定义 : enum 枚举名 { 枚举元素表 变量表 ; 例 enum weekday { sun, mon, tue, wed, thu, fri, sat 等同 day; 说明 : 1 枚举元素的值是整型常量, 定义时未指定值 : 从 0 开始, 顺序往下增 1 可指定值, 且其后也顺序往下增 1 例 enum weekday { sun=0, mon=1, tue=2, wed=3, thu=4, fri=5, sat=6; 例 enum weekday { sun=7, mon=1, tue, wed, thu, fri, sat ;.

37 2 枚举变量只能使用指定的任意一个枚举元素例 day=tue; day=2; /* 2 不是枚举元素 */ day=(enum weekday) 2; /* 但可强制类型转换 */ 3 注意, 枚举元素不可以直接输入输出 ( scanf printf 中无枚举型格式符 ), 但可输出枚举变量值 ( 枚举变量值为整型常量值 ) 例 printf( %d, day); 例 键盘输入 0~6 的任意整数, 0 表示星期日, 1 到 6 分别表示星期一到星期六, 要求编写程序输出对应的英文名称. main( ) { enum {sun, mon, tue, wed, thu, fri, sat week; int i; printf( 输入 0~6 的任意整数 (0 表示星期日, 1 到 6 分别表示星期一到星期六 ): ); scanf( %d,&i);.

38 switch(i) /* 根据变量 i 的值为枚举变量 week 赋值 */ { case 0: week=sun; break; case 1: week=mon; break; case 2: week=tue; break; case 3: week=wed; break; case 4: week=thu; break; case 5: week=fri; break; case 6: week=sat; default: printf( 输入值超出 0~6 范围.\n ); switch(week) /* 输出 */ { case sun: printf("sunday\n"); break; case mon: printf("monday\n"); break; case tue: printf("tuesday\n"); break; case wed: printf("wednesday\n"); break; case thu: printf("thursday\n"); break; case fri: printf("friday\n"); break; case sat: printf("saturday\n");. 另 :P 293 例 枚举元素用于控制循环的范围

39 10.5 用 typedef 定义类型 用 typedef 定义类型 : 是对于已经存在的类型定义一个新的名字 定义 : typedef 类型定义名 ; 例 typedef float REAL; REAL i, j; float i, j; 例 typedef struct 等同 { int num;char name[20];char sex;struct node *next; SN; SN *head, *p, *q; 例 typedef int *N; N p, a[10]; 等同 int *p, *a[10];.

40 声明一个新的类型名的方法 :P 295 说明 :P 295 ~ 296.

untitled

untitled A, 3+A printf( ABCDEF ) 3+ printf( ABCDEF ) 2.1 C++ main main main) * ( ) ( ) [ ].* ->* ()[] [][] ** *& char (f)(int); ( ) (f) (f) f (int) f int char f char f(int) (f) char (*f)(int); (*f) (int) (

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 49 [P.51] C/C++ [P.52] [P.53] [P.55] (int) [P.57] (float/double) [P.58] printf scanf [P.59] [P.61] ( / ) [P.62] (char) [P.65] : +-*/% [P.67] : = [P.68] : ,

More information

新・明解C言語入門編『索引』

新・明解C言語入門編『索引』 !... 75!=... 48 "... 234 " "... 9, 84, 240 #define... 118, 213 #include... 148 %... 23 %... 23, 24 %%... 23 %d... 4 %f... 29 %ld... 177 %lf... 31 %lu... 177 %o... 196 %p... 262 %s... 242, 244 %u... 177

More information

新版 明解C言語入門編

新版 明解C言語入門編 328, 4, 110, 189, 103, 11... 318. 274 6 ; 10 ; 5? 48 & & 228! 61!= 42 ^= 66 _ 82 /= 66 /* 3 / 19 ~ 164 OR 53 OR 164 = 66 ( ) 115 ( ) 31 ^ OR 164 [] 89, 241 [] 324 + + 4, 19, 241 + + 22 ++ 67 ++ 73 += 66

More information

新・解きながら学ぶC言語

新・解きながら学ぶC言語 330!... 67!=... 42 "... 215 " "... 6, 77, 222 #define... 114, 194 #include... 145 %... 21 %... 21 %%... 21 %f... 26 %ld... 162 %lf... 26 %lu... 162 %o... 180 %p... 248 %s... 223, 224 %u... 162 %x... 180

More information

untitled

untitled 1 DBF (READDBF.C)... 1 2 (filetest.c)...2 3 (mousetes.c)...3 4 (painttes.c)...5 5 (dirtest.c)...9 6 (list.c)...9 1 dbf (readdbf.c) /* dbf */ #include int rf,k,reclen,addr,*p1; long brec,erec,i,j,recnum,*p2;

More information

01

01 Web: www.wjsfedu.com 01 www.wjsfedu.com 02 03 www.wjsfedu.com 04 2 Daily Schedule 7/26 Tue Day 3 7/27 Wed Day 4 7/28 Thu 7/25 Mon Day 2 Day 5 7/24 Sun Day 1 7 7/29 Fri Day 6 7/30 Sat Day 7 05 7/31 Sun

More information

没有幻灯片标题

没有幻灯片标题 指针作为函数参数 : 原因 : 1 需要修改一个或多个值,( 用 return 语句不能解决问题 ) 2 执行效率的角度 使用方法 : 在函数原型以及函数首部中需要声明能够接受指针值的形参, 具体的写法为 : 数据类型 * 形参名 如果有多个指针型形参, 则用逗号分隔, 例如 : void swap(int *p1, int *p2) 它说明了形参 p1 p2 是指向整型变量的指针 在函数调用时,

More information

Generated by Unregistered Batch DOC TO PDF Converter , please register! 浙江大学 C 程序设计及实验 试题卷 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:3

Generated by Unregistered Batch DOC TO PDF Converter , please register! 浙江大学 C 程序设计及实验 试题卷 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:3 浙江大学 C 程序设计及实验 试题卷 2002-2003 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:30-10:30 注意 : 答题内容必须写在答题卷上, 写在本试题卷上无效 一. 单项选择题 ( 每题 1 分, 共 10 分 ) 1. 下列运算符中, 优先级最低的是 A.

More information

新版 明解C++入門編

新版 明解C++入門編 511!... 43, 85!=... 42 "... 118 " "... 337 " "... 8, 290 #... 71 #... 413 #define... 128, 236, 413 #endif... 412 #ifndef... 412 #if... 412 #include... 6, 337 #undef... 413 %... 23, 27 %=... 97 &... 243,

More information

untitled

untitled 不 料 料 例 : ( 料 ) 串 度 8 年 數 串 度 4 串 度 數 數 9- ( ) 利 數 struct { ; ; 數 struct 數 ; 9-2 數 利 數 C struct 數 ; C++ 數 ; struct 省略 9-3 例 ( 料 例 ) struct people{ char name[]; int age; char address[4]; char phone[]; int

More information

download.kaoyan.com_2006ÄêÌì½ò¹¤Òµ´óѧ¸ß¼¶ÓïÑÔ³ÌÐòÉè¼Æ£¨409£©¿¼ÑÐÊÔÌâ

download.kaoyan.com_2006ÄêÌì½ò¹¤Òµ´óѧ¸ß¼¶ÓïÑÔ³ÌÐòÉè¼Æ£¨409£©¿¼ÑÐÊÔÌâ 考生注意 : 本试卷共七大题, 满分 150 分 考试时间为 3 小时 ; 所有答案均写在答题纸上 ( 注明题号 ), 在此答题一律无效无效 一 选择题 ( 本题共 20 小题, 每小题 2 分, 满分 40 分 ) 1 char ch 1 2 A 0

More information

C 1

C 1 C homepage: xpzhangme 2018 5 30 C 1 C min(x, y) double C // min c # include # include double min ( double x, double y); int main ( int argc, char * argv []) { double x, y; if( argc!=

More information

C/C++ - 文件IO

C/C++ - 文件IO C/C++ IO Table of contents 1. 2. 3. 4. 1 C ASCII ASCII ASCII 2 10000 00100111 00010000 31H, 30H, 30H, 30H, 30H 1, 0, 0, 0, 0 ASCII 3 4 5 UNIX ANSI C 5 FILE FILE 6 stdio.h typedef struct { int level ;

More information

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc 2 5 8 11 0 13 1. 13 2. 15 3. 18 1 23 1. 23 2. 26 3. 28 2 36 1. 36 2. 39 3. 42 4. 44 5. 49 6. 51 3 57 1. 57 2. 60 3. 64 4. 66 5. 70 6. 75 7. 83 8. 85 9. 88 10. 98 11. 103 12. 108 13. 112 4 115 1. 115 2.

More information

untitled

untitled 1 Outline 數 料 數 數 列 亂數 練 數 數 數 來 數 數 來 數 料 利 料 來 數 A-Z a-z _ () 不 數 0-9 數 不 數 SCHOOL School school 數 讀 school_name schoolname 易 不 C# my name 7_eleven B&Q new C# (1) public protected private params override

More information

nooog

nooog C : : : , C C,,, C, C,, C ( ), ( ) C,,, ;,, ; C,,, ;, ;, ;, ;,,,, ;,,, ; : 1 9, 2 3, 4, 5, 6 10 11, 7 8, 12 13,,,,, 2008 1 1 (1 ) 1.1 (1 ) 1.1.1 ( ) 1.1.2 ( ) 1.1.3 ( ) 1.1.4 ( ) 1.1.5 ( ) 1.2 ( ) 1.2.1

More information

C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1

C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1 C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 月 3 日 1 1 INPUTOUTPUT 1 InputOutput 题目描述 用 cin 输入你的姓名 ( 没有空格 ) 和年龄 ( 整数 ), 并用 cout 输出 输入输出符合以下范例 输入 master 999 输出 I am master, 999 years old. 注意 "," 后面有一个空格,"." 结束,

More information

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit 6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C51 6.1 C51 6.1.1 C51 C51 ANSI C MCS-51 C51 ANSI C C51 6.1 6.1 C51 bit Byte bit sbit 1 0 1 unsigned char 8 1 0 255 Signed char 8 11 128

More information

Microsoft PowerPoint - 5. 指针Pointers.ppt [兼容模式]

Microsoft PowerPoint - 5. 指针Pointers.ppt [兼容模式] 指针 Pointers 变量指针与指针变量 Pointer of a variable 变量与内存 (Variables and Memory) 当你声明一个变量时, 计算机将给该变量一个内存, 可以存储变量的值 当你使用变量时, 计算机将做两步操作 : - 根据变量名查找其对应的地址 ; - 通过地址对该地址的变量内容进行读 (retrieve) 或写 (set) 变量的地址称为变量的指针! C++

More information

Microsoft PowerPoint - C语言课件-9-结构体.pptx

Microsoft PowerPoint - C语言课件-9-结构体.pptx 第九章结构体 郎大鹏 第九章结构体 9.1 结构体类型的声明方法 9.2 结构体类型变量的定义与使用 9.3 结构体数组 9.4 编程举例 9.5 习题 9.1 结构体类型的声明方法 结构体声明的语法形式如下 : struct 结构体标识符 成员变量列表 ; }; 例如, 为了描述班级 ( 假设仅仅包括班级编号 专业 人数等信息 ), 可以声明如下的结构体类型 struct Class char Code[10];

More information

C/C++ - 字符输入输出和字符确认

C/C++ - 字符输入输出和字符确认 C/C++ Table of contents 1. 2. getchar() putchar() 3. (Buffer) 4. 5. 6. 7. 8. 1 2 3 1 // pseudo code 2 read a character 3 while there is more input 4 increment character count 5 if a line has been read,

More information

Microsoft PowerPoint - C_Structure.ppt

Microsoft PowerPoint - C_Structure.ppt 結構與其他資料型態 Janet Huang 5-1 結構的宣告 struct 結構名稱 struct 結構名稱變數 1, 變數 2,, 變數 m; struct 結構名稱 變數 1, 變數 2,, 變數 m; student; student; 5-2 1 結構變數初值的設定 struct 結構名稱 struct 結構名稱變數 = 初值 1, 初值 2,, 初值 n student="janet","1350901",100,95

More information

第 10 章结构体和枚举教案 一 授课题目 ( 教学章 节或主题 ) 10.1 结构体及结构体变量 10.2 结构体数组 二 教学时间安排 上课 2 学时 三 教学目的 要求 知识目标 : 学习结构体变量和结构体数组的定义和引用能力目标 : 掌握结构体的初步应用情感目标 : 通过结构体编程实践获得成

第 10 章结构体和枚举教案 一 授课题目 ( 教学章 节或主题 ) 10.1 结构体及结构体变量 10.2 结构体数组 二 教学时间安排 上课 2 学时 三 教学目的 要求 知识目标 : 学习结构体变量和结构体数组的定义和引用能力目标 : 掌握结构体的初步应用情感目标 : 通过结构体编程实践获得成 第 10 章结构体和枚举教案 一 授课题目 ( 教学章 节或主题 ) 10.1 结构体及结构体变量 10.2 结构体数组 二 教学时间安排 上课 2 学时 三 教学目的 要求 知识目标 : 学习结构体变量和结构体数组的定义和引用能力目标 : 掌握结构体的初步应用情感目标 : 通过结构体编程实践获得成就感, 提升 C 语言编程的兴趣 四 教学重点或难点 教学重点 : 结构体数组成员的引用 教学难点 :

More information

_汪_文前新ok[3.1].doc

_汪_文前新ok[3.1].doc 普 通 高 校 本 科 计 算 机 专 业 特 色 教 材 精 选 四 川 大 学 计 算 机 学 院 国 家 示 范 性 软 件 学 院 精 品 课 程 基 金 青 年 基 金 资 助 项 目 C 语 言 程 序 设 计 (C99 版 ) 陈 良 银 游 洪 跃 李 旭 伟 主 编 李 志 蜀 唐 宁 九 李 涛 主 审 清 华 大 学 出 版 社 北 京 i 内 容 简 介 本 教 材 面 向

More information

untitled

untitled 3 C++ 3.1 3.2 3.3 3.4 new delete 3.5 this 3.6 3.7 3.1 3.1 class struct union struct union C class C++ C++ 3.1 3.1 #include struct STRING { typedef char *CHARPTR; // CHARPTR s; // int strlen(

More information

untitled

untitled 1 1.1 1.2 1.3 1.4 1.5 ++ 1.6 ++ 2 BNF 3 4 5 6 7 8 1.2 9 1.2 IF ELSE 10 1.2 11 1.2 12 1.3 Ada, Modula-2 Simula Smalltalk-80 C++, Objected Pascal(Delphi), Java, C#, VB.NET C++: C OOPL Java: C++ OOPL C# C++

More information

C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf ("%d", & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9

C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf (%d, & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9 201 201 21 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp Compilation Error long long cin scanf Time Limit Exceeded 1: A 1 B 1 C 5 D RPG 10 E 10 F 1 G II 1 1 201 201 C 1 # include 2 int main ( void

More information

C/C++语言 - C/C++数据

C/C++语言 - C/C++数据 C/C++ C/C++ Table of contents 1. 2. 3. 4. char 5. 1 C = 5 (F 32). 9 F C 2 1 // fal2cel. c: Convert Fah temperature to Cel temperature 2 # include < stdio.h> 3 int main ( void ) 4 { 5 float fah, cel ;

More information

epub 33-8

epub 33-8 8 1) 2) 3) A S C I I 4 C I / O I / 8.1 8.1.1 1. ANSI C F I L E s t d i o. h typedef struct i n t _ f d ; i n t _ c l e f t ; i n t _ m o d e ; c h a r *_ n e x t ; char *_buff; /* /* /* /* /* 1 5 4 C FILE

More information

C/C++ 语言 - 循环

C/C++ 语言 - 循环 C/C++ Table of contents 7. 1. 2. while 3. 4. 5. for 6. 8. (do while) 9. 10. (nested loop) 11. 12. 13. 1 // summing.c: # include int main ( void ) { long num ; long sum = 0L; int status ; printf

More information

untitled

untitled 串 串 例 : char ch= a ; char str[]= Hello ; 串 列 ch=getchar(); scanf( %c,&ch); 串 gets(str) scanf( %s,str); 8-1 數 ASCII 例 : char ch= A ; printf( %d,ch); // 65 A ascii =0x41 printf( %c,ch); // A 例 : char ch;

More information

PowerPoint 演示文稿

PowerPoint 演示文稿 第 12 章再谈指针 本章的基本内容是 : 指针与数组 指针与结构体 动态存储分配 由于指针可以直接对内存进行操作, 所以指针的功能非常 强大 正确灵活地使用指针可以有效地表示复杂的数据结 构, 并可动态分配内存空间, 提高程序的运行效率 任务 12.1 判断回文 问题 输入一个字符串, 判断该字符串是否为回文 ( 首尾对称的字句, 例如 abcba abba 均为回文 ) 要求用指针实现 想法 设两个指针变量

More information

FY.DOC

FY.DOC 高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主

More information

C C

C C C C 2017 3 8 1. 2. 3. 4. char 5. 2/101 C 1. 3/101 C C = 5 (F 32). 9 F C 4/101 C 1 // fal2cel.c: Convert Fah temperature to Cel temperature 2 #include 3 int main(void) 4 { 5 float fah, cel; 6 printf("please

More information

台湾项目书

台湾项目书 两 岸 医 学 人 文 交 流 项 目 Cross-Taiwan Straits Medical Humanity Exchange Program 2016 年 寒 假 台 湾 交 流 团 步 入 大 学 课 堂 学 习 深 度 认 识 台 湾 医 疗 两 岸 医 学 生 互 动 交 流 项 目 简 介 台 湾 的 医 疗 服 务 水 平 在 亚 洲 居 于 领 先 地 位 2012 年, 全 球

More information

untitled

untitled CHAPTER 02 2 CHAPTER 2-1 2-4 2-2 2-5 2-3 2-6 2-1 2-1-1 2-2 02 int A[3] = {10, 20, 30; A[0] 10 A[1] 20 A[2] 30 int *pa[3], A[3]; C 3 pa pa[0]pa[1]pa[2] 3 A A[0]A[1]A[2] 3 A A[0] A + i A[i] A + i &A[i]*(A

More information

《C语言程序设计》第2版教材习题参考答案

《C语言程序设计》第2版教材习题参考答案 教材 C 语言程序设计 ( 第 2 版 ) 清华大学出版社, 黄保和, 江弋编著 2011 年 10 月第二版 ISBN:978-7-302-26972-4 售价 :35 元 答案版本 本习题答案为 2012 年 2 月修订版本 一. 选择题 1 若已经定义 struct stu int a, b; student;, 则下列输入语句中正确的是 D)scanf( %d,&student.a) A.

More information

《C语言程序设计》教材习题参考答案

《C语言程序设计》教材习题参考答案 教材名称 : C 语言程序设计 ( 第 1 版 ) 黄保和 江弋编著清华大学出版社 ISBN: 978-7-302-13599-9, 红色封面 答案制作时间 :2011 年 2 月 -5 月 一 选择题 1 若已经定义 struct stu int a, b; student;, 则下列输入语句中正确的是 D)scanf( %d,&student.a); 2 若已有以下结构体定义, 则值为 2 的表达式是

More information

chap07.key

chap07.key #include void two(); void three(); int main() printf("i'm in main.\n"); two(); return 0; void two() printf("i'm in two.\n"); three(); void three() printf("i'm in three.\n"); void, int 标识符逗号分隔,

More information

C/C++ - 函数

C/C++ - 函数 C/C++ Table of contents 1. 2. 3. & 4. 5. 1 2 3 # include # define SIZE 50 int main ( void ) { float list [ SIZE ]; readlist (list, SIZE ); sort (list, SIZE ); average (list, SIZE ); bargragh

More information

プログラムの設計と実現II

プログラムの設計と実現II UNIX C ls mkdir man http://www.tj.chiba-u.jp/lecture/prog2/ Ctrl+x, Ctrl+s ( )..[4]% gcc Wall o hoge hoge.c..[5]%./hoge 1 : 1 2 : 2 3 : 3 4 : 0 6..[6]% (! )..[4]% gcc Wall o hoge hoge.c..[5]%!g gcc Wall

More information

2015年计算机二级(C语言)模拟试题及答案(四)

2015年计算机二级(C语言)模拟试题及答案(四) 2016 年 计 算 机 二 级 (C 语 言 ) 模 拟 试 题 及 答 案 (4) 一 填 空 题 1 C 语 言 中 基 本 的 数 据 类 型 有 : 2 C 语 言 中 普 通 整 型 变 量 的 类 型 说 明 符 为, 在 内 存 中 占 字 节, 有 符 号 普 通 整 型 的 数 据 范 围 是 3 整 数 -35 在 机 内 的 补 码 表 示 为 4 执 行 下 列 语 句 int

More information

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf ("%d", & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf ("%d %d

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf (%d, & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf (%d %d 2013 18 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp, Compilation Error cin scanf Time Limit Exceeded 1: A 5 B 5 C 5 D 5 E 5 F 5 1 2013 C 1 # include 2 int main ( void ) 3 { 4 int cases, a, b,

More information

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++;

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; Memory & Pointer trio@seu.edu.cn 2.1 2.1.1 1 int *p int a 0x00C7 0x00C7 0x00C7 2.1.2 2 int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; 2.1.3 1. 2. 3. 3 int A,

More information

PowerPoint 演示文稿

PowerPoint 演示文稿 STC 单片机复杂数据结构 主讲 : 何宾 Email:hebin@mail.buct.edu.cn 2016.03 结构类型定义的格式为 : struct 结构名 } 其中 : 结构元素列表 结构 -- 结构类型的定义 结构元素列表为不同数据类型的列表 结构 -- 结构类型的定义 例 16-1 结构体的声明例子 struct student char name[30]; char gender;

More information

OOP with Java 通知 Project 2 提交时间 : 3 月 14 日晚 9 点 另一名助教 : 王桢 学习使用文本编辑器 学习使用 cmd: Power shell 阅读参考资料

OOP with Java 通知 Project 2 提交时间 : 3 月 14 日晚 9 点 另一名助教 : 王桢   学习使用文本编辑器 学习使用 cmd: Power shell 阅读参考资料 OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 2 提交时间 : 3 月 14 日晚 9 点 另一名助教 : 王桢 Email: 51141201063@ecnu.cn 学习使用文本编辑器 学习使用 cmd: Power shell 阅读参考资料 OOP with Java Java 类型 引用 不可变类型 对象存储位置 作用域 OOP

More information

untitled

untitled 1-1 1-2 1-3 1-4 1-5 1-6 1-7 1-8 1-1-1 C int main(void){ int x,y,z; int sum=0; double avg=0.0; scanf("%d",&x) ; scanf("%d",&y) ; scanf("%d",&z) ; sum=x+y+z ; avg=sum/3.0; printf("%f\n",avg); system("pause");

More information

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023)

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023) ( CIP) /. :, 2005. 2 ( ) ISBN 7-5624-3339-9.......... TP311. 1 CIP ( 2005) 011794 : : : : * : : 174 ( A ) :400030 : ( 023) 65102378 65105781 : ( 023) 65103686 65105565 : http: / /www. cqup. com. cn : fxk@cqup.

More information

c_cpp

c_cpp C C++ C C++ C++ (object oriented) C C++.cpp C C++ C C++ : for (int i=0;i

More information

說 明, 成 個 體 統 才 是! 你 痰 迷 了 心, 脂 油 蒙 了 竅, 國 孝 家 孝 兩 重 在 身, 就 把 個 人 送 來 了 這 會 子 被 人 家 告 我 們, 我 又 是 個 沒 腳 蟹, 連 官 場 中 都 知 道 我 利 害 吃 醋, 如 今 指 名 提 我, 要 休 我,

說 明, 成 個 體 統 才 是! 你 痰 迷 了 心, 脂 油 蒙 了 竅, 國 孝 家 孝 兩 重 在 身, 就 把 個 人 送 來 了 這 會 子 被 人 家 告 我 們, 我 又 是 個 沒 腳 蟹, 連 官 場 中 都 知 道 我 利 害 吃 醋, 如 今 指 名 提 我, 要 休 我, 國 文 91 年 學 科 能 力 測 驗 總 分 班 級 : / 座 號 : / 姓 名 : 第 壹 部 分 : 選 擇 題 ( 占 54 分 ) 一 單 一 選 擇 題 ( 占 36 分 ) 說 明 : 第 1 題 至 第 18 題, 每 題 選 出 一 個 最 適 當 的 選 項, 標 示 在 答 案 卡 之 選 擇 題 答 案 區 每 題 答 對 得 2 分, 答 錯 不 倒 扣 ( )1.

More information

C/C++语言 - 运算符、表达式和语句

C/C++语言 - 运算符、表达式和语句 C/C++ Table of contents 1. 2. 3. 4. C C++ 5. 6. 7. 1 i // shoe1.c: # include # define ADJUST 7. 64 # define SCALE 0. 325 int main ( void ) { double shoe, foot ; shoe = 9. 0; foot = SCALE * shoe

More information

试卷代号 :1253 座位号 E 口 国家开放大学 ( 中央广播电视大学 )2014 年秋季学期 " 开放本科 " 期末考试 C 语言程序设计 A 试题 2015 年 1 月 E 四! 五 总分! 一 单选题 ( 每小题 2 分, 共 20 分 ) 1. 由 C 语言源程序文件编译而成的目标文件的默

试卷代号 :1253 座位号 E 口 国家开放大学 ( 中央广播电视大学 )2014 年秋季学期  开放本科  期末考试 C 语言程序设计 A 试题 2015 年 1 月 E 四! 五 总分! 一 单选题 ( 每小题 2 分, 共 20 分 ) 1. 由 C 语言源程序文件编译而成的目标文件的默 试卷代号 :1253 座位号 E 口 国家开放大学 ( 中央广播电视大学 )2014 年秋季学期 " 开放本科 " 期末考试 C 语言程序设计 A 试题 2015 年 1 月 E 四! 五 总分! 一 单选题 ( 每小题 2 分, 共 20 分 ) 1. 由 C 语言源程序文件编译而成的目标文件的默认扩展名为 ( ) A. cpp B. c C. exe D. obj 2. 设 x 和 y 均为逻辑值,

More information

Microsoft Word - 2012年6月號墾汀排版.doc

Microsoft Word - 2012年6月號墾汀排版.doc 目 錄 編 者 的 話 郭 洪 龍 目 錄 1 牧 者 家 書 石 林 潤 鳳 2 證 道 權 能 感 恩 的 人 張 振 華 牧 師 筆 錄 : 張 秀 儀 5 特 稿 畢 業 = 成 功?! 章 可 銘 10 雲 彩 片 片 主 的 深 恩 永 遠 記 在 心 陳 淑 貞 15 恩 典 歲 月 謝 周 淑 珍 22 禱 告, 我 願 意 : 為 敏 玲 送 上 祝 福! 謝 周 淑 珍 27 非

More information

Microsoft Word - 2008年9月二级C真卷.doc

Microsoft Word - 2008年9月二级C真卷.doc 机 密 启 用 前 2008 年 9 月 全 国 计 算 机 等 级 考 试 二 级 笔 试 试 卷 C 语 言 程 序 设 计 24 注 意 事 项 一 考 生 应 严 格 遵 守 考 场 规 则, 得 到 监 考 人 员 指 令 后 方 可 作 答 二 考 生 拿 到 试 卷 后 应 首 先 将 自 己 的 姓 名 准 考 证 号 等 内 容 涂 写 在 答 题 卡 的 相 应 位 置 上 三

More information

C/C++ - 字符串与字符串函数

C/C++ - 字符串与字符串函数 C/C++ Table of contents 1. 2. 3. 4. 1 char C 2 char greeting [50] = " How " " are " " you?"; char greeting [50] = " How are you?"; 3 printf ("\" Ready, go!\" exclaimed John."); " Ready, go!" exclaimed

More information

12 41 43 春 新 春 年 貨 年 菜 來 這 買 市 場 超 人 氣 美 食 增 添 豐 富 團 圓 好 滋 味 來 臺 北 過 好 年 2 月 4 日 熱 鬧 登 場 盡 情 揪 團 享 受 11 處 商 圈 新 春 採 買 樂 趣 妝 點 花 樣 生 活 花 開 富 貴 過 好 年 最

12 41 43 春 新 春 年 貨 年 菜 來 這 買 市 場 超 人 氣 美 食 增 添 豐 富 團 圓 好 滋 味 來 臺 北 過 好 年 2 月 4 日 熱 鬧 登 場 盡 情 揪 團 享 受 11 處 商 圈 新 春 採 買 樂 趣 妝 點 花 樣 生 活 花 開 富 貴 過 好 年 最 104 年 1 月 30 日 發 行 / 月 刊 發 行 人 臺 北 市 市 場 處 處 長 王 三 中 臺 北 市 商 業 處 處 長 黃 以 育 出 版 機 關 臺 北 市 市 場 處 臺 北 市 中 正 區 羅 斯 福 路 一 段 8 號 3 樓 http://www.tcma.taipei.gov.tw 臺 北 市 商 業 處 臺 北 市 信 義 區 市 府 路 1 號 北 區 1 樓 http://www.tcooc.taipei.gov.tw

More information

网C试题(08上).doc

网C试题(08上).doc 学习中心 姓名 学号 西安电子科技大学网络与继续教育学院 高级语言程序设计 (C) 全真试题 ( 闭卷 90 分钟 ) 题号一二三总分 题分 60 20 20 得分 一 单项选择题 ( 每小题 3 分, 共 60 分 ) 1.C 语言程序的基本单位是 A) 程序行 B) 语句 C) 函数 D) 字符 2. 下列四组选项中, 均是不合法的用户标识符的选项是 A)A B)getc C)include D)while

More information

<4D F736F F D20D7DBBACFCAD4CCE231B2CEBFBCB4F0B0B82E646F63>

<4D F736F F D20D7DBBACFCAD4CCE231B2CEBFBCB4F0B0B82E646F63> 综合测试题一参考答案 一 填空题 ( 表达式求值 )( 本大题共 10 小题, 每小题 1 分, 共 10 分 ) 设各语句的初始化 相同 :int x=3,y=2,z=1; 1. x=y==z x= 0 2. x=!(z>y)&&!x 1 x= 1 3. x=(y++*1/3) x= 0 4. x=((x>y>z)?1:0) x= 0 5. x*=2+3 x= 15 6. x=(++z*y,y++,z%y)

More information

C/C++语言 - 分支结构

C/C++语言 - 分支结构 C/C++ Table of contents 1. if 2. if else 3. 4. 5. 6. continue break 7. switch 1 if if i // colddays.c: # include int main ( void ) { const int FREEZING = 0; float temperature ; int cold_ days

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 177 [P179] (1) - [P181] [P182] (2) - for [P183] (3) - switch [P184] [P187] [P189] [P194] 178 [ ]; : : int var; : int var[3]; var 2293620 var[0] var[1] 2293620

More information

C/C++ - 结构体、共用体、枚举体

C/C++ - 结构体、共用体、枚举体 C/C++ Table of contents 1. 2. 3. 4. 5. 6. 7. 8. 1 C C (struct) C 2 C C (struct) C 2 i // book.c: # include < stdio.h> # define MAX_ TITLE 41 # define MAX_ AUTHOR 31 struct book { char title [ MAX_ TITLE

More information

C

C C 2017 4 1 1. 2. while 3. 4. 5. for 6. 2/161 C 7. 8. (do while) 9. 10. (nested loop) 11. 12. 3/161 C 1. I 1 // summing.c: 2 #include 3 int main(void) 4 { 5 long num; 6 long sum = 0L; 7 int status;

More information

Microsoft PowerPoint - 20-string-s.pptx

Microsoft PowerPoint - 20-string-s.pptx String 1 String/ 1.: char s1[10]; char *s2; char s3[] = "Chan Tai Man"; char s4[20] = "Chan Siu Ming"; char s5[]={'h','e','l','l','o','\0'; 0 1 2 3 4 5 6 7 8 9 10 11 12 s3 C h a n T a i \0 M a n \0 printf

More information

工业和信息化部 水利部 全国节约用水办公室

工业和信息化部 水利部 全国节约用水办公室 附 件 : 国 家 节 水 标 杆 企 业 和 标 杆 指 标 ( 第 一 批 ) 序 号 企 业 名 称 产 品 名 称 1 太 原 钢 铁 ( 集 团 ) 有 限 公 司 不 锈 钢 标 杆 指 标 ( 单 位 产 品 取 水 量 ) 1.45 m 3 /t ( 再 生 水 用 量 占 总 用 水 量 的 50%) 2 莱 芜 钢 铁 集 团 有 限 公 司 H 型 钢 齿 轮 钢 3.43m

More information

2

2 : Mariposa ( ), : Memory : a : (Sat Dec 30 20:59:30 2006), 2006 1 2 NO.1 3 4 5 : Mariposa ( ), : Memory : b : (Sun Dec 31 16:26:22 2006), 6 7 8 9 : Mariposa ( ), : Memory : c : (Tue Jan 2 15:35:35 2007),

More information

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File

1 Project New Project 1 2 Windows 1 3 N C test Windows uv2 KEIL uvision2 1 2 New Project Ateml AT89C AT89C51 3 KEIL Demo C C File 51 C 51 51 C C C C C C * 2003-3-30 pnzwzw@163.com C C C C KEIL uvision2 MCS51 PLM C VC++ 51 KEIL51 KEIL51 KEIL51 KEIL 2K DEMO C KEIL KEIL51 P 1 1 1 1-1 - 1 Project New Project 1 2 Windows 1 3 N C test

More information

C/C++程序设计 - 字符串与格式化输入/输出

C/C++程序设计 - 字符串与格式化输入/输出 C/C++ / Table of contents 1. 2. 3. 4. 1 i # include # include // density of human body : 1. 04 e3 kg / m ^3 # define DENSITY 1. 04 e3 int main ( void ) { float weight, volume ; int

More information

untitled

untitled 香港觀鳥會 紅耳鵯俱樂部 2009 1 20 22/11[] 1225 ( ) [ ] 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 23/11[] () 1130 20 3 1. (1.5 )2. (2.5 ) 3. 峄 (4.5 ) 1 20 Bill Bill 5:00 5:30 6:00 1. 2. 3. 4. 5. 6. 7 8. 9. 10. 11. 12 13,

More information

程序设计与算法语言 结构体 共同体和枚举类型 C/C++ Programming and Algorithms struct, union and enum types Dongke Sun ( 孙东科 ) 东南大学机械工程学院 School of Mechanic

程序设计与算法语言 结构体 共同体和枚举类型 C/C++ Programming and Algorithms struct, union and enum types Dongke Sun ( 孙东科 ) 东南大学机械工程学院 School of Mechanic 程序设计与算法语言 结构体 共同体和枚举类型 C/C++ Programming and Algorithms struct, union and enum types Dongke Sun ( 孙东科 ) dksun@seu.edu.cn 东南大学机械工程学院 School of Mechanical Engineering Southeast University Spring semester,

More information

第5章修改稿

第5章修改稿 (Programming Language), ok,, if then else,(), ()() 5.0 5.0.0, (Variable Declaration) var x : T x, T, x,,,, var x : T P = x, x' : T P P, () var x:t P,,, yz, var x : int x:=2. y := x+z = x, x' : int x' =2

More information

Microsoft Word - 专升本练习2:线性表.doc

Microsoft Word - 专升本练习2:线性表.doc 第二章 线性表 一 选择题 1. 线性表是 ( ) A. 一个有限序列, 可以为空 B. 一个有限序列, 不能为空 C. 一个有限序列, 可以为空 D. 一个无序序列, 不能为空 2. 对顺序存储的线性表, 设其长度为 n, 在任何位置上插入或删除操作都是等概率 插入一个元素 时大约要移动表中的 ( ) 个元素, 删除一个元素时大约要移动表中的 ( ) 个元素 A. n/2 B. (n+1)/2 C.

More information

WARNING RISK OF ELECTRIC SHOCK DO NOT OPEN AVIS RISQUE DE CHOC ELECTRIQUE NE PAS OUVRIR S35A Ct-

WARNING RISK OF ELECTRIC SHOCK DO NOT OPEN AVIS RISQUE DE CHOC ELECTRIQUE NE PAS OUVRIR S35A Ct- CR-B8 Ct WARNING RISK OF ELECTRIC SHOCK DO NOT OPEN AVIS RISQUE DE CHOC ELECTRIQUE NE PAS OUVRIR S35A...... Ct- Ct-3 Ct-4 3 Ct-5 Ct-6 Ct-7 3 4 5 6 7 8 9 J K L A B C D E F G H I M N O P Q R S T U J K L

More information

Microsoft PowerPoint - ds-1.ppt [兼容模式]

Microsoft PowerPoint - ds-1.ppt [兼容模式] http://jwc..edu.cn/jxgl/ HomePage/Default.asp 2 说 明 总 学 时 : 72( 学 时 )= 56( 课 时 )+ 16( 实 验 ) 行 课 时 间 : 第 1 ~14 周 周 学 时 : 平 均 每 周 4 学 时 上 机 安 排 待 定 考 试 时 间 : 课 程 束 第 8 11 12 章 的 内 容 为 自 学 内 容 ; 目 录 中 标 有

More information

C

C C 14 2017 5 31 1. 2. 3. 4. 5. 2/101 C 1. ( ) 4/101 C C ASCII ASCII ASCII 5/101 C 10000 00100111 00010000 ASCII 10000 31H 30H 30H 30H 30H 1 0 0 0 0 0 ASCII 6/101 C 7/101 C ( ) ( ) 8/101 C UNIX ANSI C 9/101

More information

《C语言程序设计》教材习题参考答案

《C语言程序设计》教材习题参考答案 教材名称 : C 语言程序设计 ( 第 1 版 ) 黄保和 江弋编著清华大学出版社 ISBN:978-7-302-13599-9, 红色封面 答案制作时间 :2011 年 2 月 -5 月 一 选择题 1. 设已定义 int a, * p, 下列赋值表达式中正确的是 :C)p=&a 2. 设已定义 int x,*p=&x;, 则下列表达式中错误的是 :B)&*x 3. 若已定义 int a=1,*b=&a;,

More information

untitled

untitled 1 5 IBM Intel 1. IBM 第 1/175 页 第 2/175 页 第 3/175 页 80 第 4/175 页 2. IBM 第 5/175 页 3. (1) 第 6/175 页 第 7/175 页 第 8/175 页 = = 第 9/175 页 = = = = = 第 10/175 页 = = = = = = = = 3. (2) 第 11/175 页 第 12/175 页 第 13/175

More information

《C语言程序设计》第2版教材习题参考答案

《C语言程序设计》第2版教材习题参考答案 教材 C 语言程序设计 ( 第 2 版 ) 清华大学出版社, 黄保和, 江弋编著 2011 年 10 月第二版 ISBN:978-7-302-26972-4 售价 :35 元 答案版本 本习题答案为 2012 年 2 月修订版本 一 选择题 1. 设已定义 int a, * p, 下列赋值表达式中正确的是 :C)p = &a A. *p = *a B. p = *a C.p = &a D. *p =

More information

1 2005 9 2005,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : 100081 : : 7871092 1 /16 : 8. 75 : 96 : 2005 11 1 : 2005 11 1 : ISBN 7

1 2005 9 2005,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : 100081 : : 7871092 1 /16 : 8. 75 : 96 : 2005 11 1 : 2005 11 1 : ISBN 7 1 2005 9 2005,,,,,,,,,, ( http: \ \ www. ncre. cn,, ) 30,,,,,,,, C : C : : 19 : 100081 : : 7871092 1 /16 : 8. 75 : 96 : 2005 11 1 : 2005 11 1 : ISBN 7-80097 - 564-9 /TP 8 : 10. 00 ,,,, 1994 NCRE,,, ( ),,,,,

More information

试卷格式

试卷格式 一 基本知识题 (10 分 ) 1.1. 已知定义 :int a=0; 请指出以下不会产生死循环的控制结构 A)for( ; ; ) if(a) break; B)for( ; ; a=0) if(a) break; C)for( ; ; ) if(a) continue; D)for( ; a=0 ; ) if(a) break; 1.2. 请指出正确描述实参和形参关系的命题 A) 如果实参是数组名,

More information

C/C++ - 数组与指针

C/C++ - 数组与指针 C/C++ Table of contents 1. 2. 3. 4. 5. 6. 7. 8. 1 float candy [ 365]; char code [12]; int states [50]; 2 int array [6] = {1, 2, 4, 6, 8, 10}; 3 // day_mon1.c: # include # define MONTHS 12 int

More information

WARNING RISK OF ELECTRIC SHOCK DO NOT OPEN AVIS RISQUE DE CHOC ELECTRIQUE NE PAS OUVRIR S3125A Ct-2

WARNING RISK OF ELECTRIC SHOCK DO NOT OPEN AVIS RISQUE DE CHOC ELECTRIQUE NE PAS OUVRIR S3125A Ct-2 DR-UN7 Ct WARNING RISK OF ELECTRIC SHOCK DO NOT OPEN AVIS RISQUE DE CHOC ELECTRIQUE NE PAS OUVRIR S3125A...... Ct-2 1 Ct-3 Ct-4 Ct-5 ...2...3...5...5...6...8...10...10...10...11...11...12...13...14...16...18...18...18...19...19

More information

全国计算机技术与软件专业技术资格(水平)考试

全国计算机技术与软件专业技术资格(水平)考试 全 国 计 算 机 技 术 与 软 件 专 业 技 术 资 格 ( 水 平 ) 考 试 2008 年 上 半 年 程 序 员 下 午 试 卷 ( 考 试 时 间 14:00~16:30 共 150 分 钟 ) 试 题 一 ( 共 15 分 ) 阅 读 以 下 说 明 和 流 程 图, 填 补 流 程 图 中 的 空 缺 (1)~(9), 将 解 答 填 入 答 题 纸 的 对 应 栏 内 [ 说 明

More information

Microsoft Word - 第3章.doc

Microsoft Word - 第3章.doc Java C++ Pascal C# C# if if if for while do while foreach while do while C# 3.1.1 ; 3-1 ischeck Test() While ischeck while static bool ischeck = true; public static void Test() while (ischeck) ; ischeck

More information

新・解きながら学ぶJava

新・解きながら学ぶJava 481! 41, 74!= 40, 270 " 4 % 23, 25 %% 121 %c 425 %d 121 %o 121 %x 121 & 199 && 48 ' 81, 425 ( ) 14, 17 ( ) 128 ( ) 183 * 23 */ 3, 390 ++ 79 ++ 80 += 93 + 22 + 23 + 279 + 14 + 124 + 7, 148, 16 -- 79 --

More information

C PICC C++ C++ C C #include<pic.h> C static volatile unsigned char 0x01; static volatile unsigned char 0x02; static volatile unsigned cha

C PICC C++ C++ C C #include<pic.h> C static volatile unsigned char 0x01; static volatile unsigned char 0x02; static volatile unsigned cha CYPOK CYPOK 1 UltraEdit Project-->Install Language Tool: Language Suite----->hi-tech picc Tool Name ---->PICC Compiler Executable ---->c:hi-picinpicc.exe ( Command-line Project-->New Project-->File Name--->myc

More information

2015年计算机二级(C语言)模拟试题及答案(三)

2015年计算机二级(C语言)模拟试题及答案(三) 2016 年计算机二级 (C 语言 ) 模拟试题及答案 (3) 1.( A ) 是构成 C 语言程序的基本单位 A 函数 B 过程 C 子程序 D 子例程 2.C 语言程序从 ( C ) 开始执行 A 程序中第一条可执行语句 B 程序中第一个函数 C 程序中的 main 函数 D 包含文件中的第一个函数 3 以下说法中正确的是( C ) A C 语言程序总是从第一个定义的函数开始执行 B 在 C 语言程序中,

More information

2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf("%d", &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf("%

2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf(%d, &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf(% 2013 ( 28 ) ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp Compilation Error long long cin scanf Time Limit Exceeded 1: A 10 B 1 C 1 D 5 E 5 F 1 G II 5 H 30 1 2013 C 1 #include 2 int main(void) 3

More information

Microsoft Word - 数据结构实训与习题725xdy.doc

Microsoft Word - 数据结构实训与习题725xdy.doc 第一部分学习指导与实训 3 第 2 章线性表 2.1 学习指南 (1) 理解线性表的类型定义, 掌握顺序表和链表的结构差别 (2) 熟练掌握顺序表的结构特性, 熟悉顺序表的存储结构 (3) 熟练掌握顺序表的各种运算, 并能灵活运用各种相关操作 (4) 熟练掌握链式存储结构特性, 掌握链表的各种运算 2.2 内容提要 线性表的特点 : 线性表由一组数据元素构成, 表中元素属于同一数据对象 在线性表中,

More information

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.07.doc

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.07.doc 2 5 8 11 0 1. 13 2. 15 3. 18 1 1. 22 2. 25 3. 27 2 1. 35 2. 38 3. 41 4. 43 5. 48 6. 50 3 1. 56 2. 59 3. 63 4. 65 5. 69 13 22 35 56 6. 74 7. 82 8. 84 9. 87 10. 97 11. 102 12. 107 13. 111 4 114 1. 114 2.

More information

Microsoft PowerPoint - 6. 用户定义类型User-defined Datatypes.ppt [兼容模式]

Microsoft PowerPoint - 6. 用户定义类型User-defined Datatypes.ppt [兼容模式] 用户定义类型 User-defined Datatypes classes and structs 几何向量 (Geometry Vector) 二维平面上的向量由起点和终点构成 每个点包含两个坐标 (x, y), 因此一个向量需要四个实数表示 Start= (0.9,1.5) Start= (0.4,0.8) int main() { double xstart = 0.4; double xend

More information

目录

目录 ALTERA_CPLD... 3 11SY_03091... 3 12SY_03091...4....5 21 5 22...8 23..10 24..12 25..13..17 3 1EPM7128SLC.......17 3 2EPM7032SLC.......18 33HT46R47......19..20 41..20 42. 43..26..27 5151DEMO I/O...27 52A/D89C51...28

More information

Ps22Pdf

Ps22Pdf C ( CIP) C /. :, 2001. 7 21 ISBN 7-5624 -2355-5. C........ C. TP312 CIP ( 2001 ) 034496 C * * : 7871092 1 /16 : 14. 25 : 356 20017 1 20017 1 : 1 6 000 ISBN 7-5624-2355-5 / TP311 : 21. 00 C, C,,,, C,, (

More information

Page 3. ( ). ( ). ( ) ( ) ( ), Polar

Page 3. ( ). ( ). ( ) ( ) ( ), Polar Cover 1 Polar RS200 TM Polar RS200sd TM Page 20 RS200 / RS200sd Polar Page 3. ( ). ( ). ( ) ( ) ( ), Polar Page 4 RS200sd Polar S1 TM Polar 1. POLAR RS200/RS200sd...6 1.1...6 1.2... 7 2....9 2.1...9 2.2

More information

<5B BECBB0EDB8AEC1F25D312D34B0AD5FC3E2BCAEBCF6BEF7C0DAB7E F31702E504446>

<5B BECBB0EDB8AEC1F25D312D34B0AD5FC3E2BCAEBCF6BEF7C0DAB7E F31702E504446> : 2 = 3 4? 0 an ordered set of unambiguous, executable steps that produces a result and terminates in a finite time (computational theory) ( ) 5 6 (C-) int min, max; float degree, b; char ch, token; /,,,

More information

C++ 程式設計

C++ 程式設計 C C 料, 數, - 列 串 理 列 main 數串列 什 pointer) 數, 數, 數 數 省 不 不, 數 (1) 數, 不 數 * 料 * 數 int *int_ptr; char *ch_ptr; float *float_ptr; double *double_ptr; 數 (2) int i=3; int *ptr; ptr=&i; 1000 1012 ptr 數, 數 1004

More information

C语言的应用.PDF

C语言的应用.PDF AVR C 9 1 AVR C IAR C, *.HEX, C,,! C, > 9.1 AVR C MCU,, AVR?! IAR AVR / IAR 32 ALU 1KBytes - 8MBytes (SPM ) 16 MBytes C C *var1, *var2; *var1++ = *--var2; AVR C 9 2 LD R16,-X ST Z+,R16 Auto (local

More information

中 六 同 學 清 理 儲 物 櫃 中 六 同 學 行 將 畢 業 離 校, 請 家 長 督 促 中 六 同 學 於 2016 年 2 月 22 日 ( 星 期 一 ) 前 妥 善 清 理 儲 物 櫃 內 之 各 項 物 品 家 長 日 預 告 本 年 度 之 家 長 日 將 於 1 月 31 日

中 六 同 學 清 理 儲 物 櫃 中 六 同 學 行 將 畢 業 離 校, 請 家 長 督 促 中 六 同 學 於 2016 年 2 月 22 日 ( 星 期 一 ) 前 妥 善 清 理 儲 物 櫃 內 之 各 項 物 品 家 長 日 預 告 本 年 度 之 家 長 日 將 於 1 月 31 日 2016 年 1 月 號 本 期 重 要 消 息 : 1. 農 曆 新 年 假 期 2. 中 一 級 區 本 課 後 功 課 輔 導 班 ( 第 二 期 ) 3. 家 長 日 預 告 4. 中 六 模 擬 考 試 5. 中 三 升 中 四 講 座 農 曆 新 年 假 期 2 月 5 日 至 2 月 13 日 共 9 天, 為 農 曆 新 年 假 期, 學 生 毋 須 上 課 各 同 學 請 於 2

More information

Microsoft Word - 01.DOC

Microsoft Word - 01.DOC 第 1 章 JavaScript 简 介 JavaScript 是 NetScape 公 司 为 Navigator 浏 览 器 开 发 的, 是 写 在 HTML 文 件 中 的 一 种 脚 本 语 言, 能 实 现 网 页 内 容 的 交 互 显 示 当 用 户 在 客 户 端 显 示 该 网 页 时, 浏 览 器 就 会 执 行 JavaScript 程 序, 用 户 通 过 交 互 式 的

More information

华恒家庭网关方案

华恒家庭网关方案 LINUX V1.5 1 2 1 2 LINUX WINDOWS PC VC LINUX WINDOWS LINUX 90% GUI LINUX C 3 REDHAT 9 LINUX PC TFTP/NFS http://www.hhcn.com/chinese/embedlinux-res.html minicom NFS mount C HHARM9-EDU 1 LINUX HHARM9-EDU

More information