Microsoft PowerPoint - 0 C复习.ppt [兼容模式]
|
|
- 培婴 甘
- 4 years ago
- Views:
Transcription
1 C 复习 董洪伟 1
2 程序 : 数据 + 处理 ( 运算 ) 数据 : 变量和常量 int i = 3; 初始化式 变量需要定义 : 类型变量名 ; 类型变量名 = 变量或常量 ; doule pi, r=3.45,area; char var= A ; 类型变量 1, 变量 2, 变量 3; 同时定义多个变量, 逗号隔开 2
3 运算 : 用运算符对数据进行处理 y = x*y-2/y; 算术 :+ - * / % 关系 :==!= < > <= >= 逻辑 :&&! 位运算 :& ^ 赋值 := *= %= <<= &= = 其他 :sizeof?:( 条件 ) &( 取地址 ) * ( 取内容 ) 3
4 表达式 : 运算符 + 数据 表达式的结果也是数据 : 表达式嵌套 y = x*y-2/y; 语句 : 以分号结尾的表达式 程序块 :1 个或一系列语句 函数 : 命名的程序块 以便多次调用 这个程序块 4
5 一个简单程序 :z=x+y: /* calculate z= x+y */ #include<stdio.h> int main(){ int x,y =40; int z = x+y; printf( x+y=:%d,z); } 注释 : 解释程序的功能 包含头文件 : 函数的定义等 程序的主函数 两个输入变量 x,y 输出变量 z 等于表达式 x+y 的值函数调用表达式 xy.c compiler xy.obj linker xy.exe C 函数库 5
6 编程环境 visual studio 2015 Code blocks gcc/g++ >gcc -o xy xy.c >xy >cl xy.c /out xy >xy 6
7 编程环境
8 z=x+y :xy.c /* calculate z= x+y */ #include<stdio.h> int main(){ } int x,y =40; int z = x+y; 常量 printf( x+y=:%d,z); 表达式 :y=50 x+y z= x+y printf( ) 三个整型变量 : x,y,z 在内存中各有一块独立的空间 (4 个字节 ) x? y 40 z? 三个表达式语句 表达式 : 变量 常数和运算符构成 语句 : 后跟 ; 的表达式
9 程序内存布局 系统程序 内存 : 存放程序代码和数据的地方 动态链接库应用程序 1 应用程序 2 程序代码 静态数据 堆栈区 表达式语句 函数调用栈 x,y,z 堆空间 空闲 9
10 程序错误 语法错误 : 编译错误或链接错误编译器和连接器会告诉我们错误信息! 逻辑错误 : 运行的结果和预想的不一致! int main(){ int x,y =40; int z = x+y; printf( x+y=:%d,z); } 该程序编译链接没有问题, 但输出结果有问题 -- 逻辑错误! 因为 x 没有初始化! 10
11 如何发现逻辑错误? 方法 1: 输出程序运行过程中的一些数据或信息 如 printf int main(){ } int x,y =40; int z = x+y; printf( x+y=:%d,z); 方法 2: 利用 IDE 开发环境提供的调试功能, 如断点调试 单步调试 进入函数 11
12 变量及其类型 类型 : 规定了该类型变量占内存大小 值的取值范围 对这种类型变量能进行说明操作? 变量 : 存储一个类型值的空间 int a = 3; 初始化 整型 整型的一个变量 12
13 sizeof 运算符 13
14 类型规定了值和操作 bool 的值 :true,false bool 的操作 &&,,! 推论 : 运算符对同类型 ( 或能转换为同类型 ) 的变量进行运算 14
15 自动类型转换 15
16 强制类型转换 16
17 内在类型和用户定义类型 内在类型包含 : 基本类型 :int, float, char, 数组类型 :int A[10] 指针类型 : int *p; 用户定义类型 : 枚举 enum, 结构 struct, enum RGB{red,green blue}; struct student{ char name[30]; float score; }; 17
18 访问结构成员 struct student s; strcpy(s.name, LiPin ); s.score = 78.8; 18
19 变量指针与指针变量 变量指针 : 变量的地址, 用 & 运算符获取 指针变量 : 存放指针的变量. 用 * 可以获取指针变量指向的那个变量. int i = 30; int *j = &i; //j 是存放整型变量指针的指针变量 int k = *j; // 即 k=i=30 *j = 35; // 即 i=35 双斜杠 // 表示的是单行注释 19
20 通过结构指针访问结构成员 struct student s; strcpy(s.name, LiPin ); s.score = 78.5; struct student *sp = &s; sp->score = 90.5; (*sp).score = 60; 20
21 值类型与引用类型 C 语言只有值类型 直接盛放自身数据 每个变量都有自身的值的一份拷贝 对一个值的修改不会影响另外一个值 运行栈 b 012 a 1 00A4 00A0 程序代码 int a = 1; int b; b = a; b = 2; 21
22 值类型与引用类型 指针类型 ( 也属于值类型 ) 保存的是另外一个变量的内存地址 运行栈 程序代码 int a = 1; p a NULL 00A A4 00A0 int* p; p = &a; *p = 2; 22
23 值类型与引用类型 C++ 的引用类型 简单理解 : 一个变量的别名 运行栈 程序代码 b a 12 00A0 int a = 1; int& b = a; b = 2; 23
24 值类型与引用类型 引用变量 : 1) 引用变量不过是已经存在变量的别名. 2) 既然是引用变量, 定义时就必须初始化它 3) 一旦定义, 就不能在修改引用别的变量 int a = 3; int &b = a; int &b = c; char &d = a; 24
25 表达式和语句 表达式 : 由常量 变量和运算符构成 对数据进行加工 语句 : 表达式后跟分号 除直接对数据进行运算的语句外, 还有程序流程控制语句, 如 if for while switch 等 程序块 : 一个或多个语句构成, 如 if for while switch 或 { } 等. 函数就是一个命名的程序块 25
26 程序块 void main(){ int x=3,y=4; { int t = x; x=y; y =t } t++; } t 是 { } 程序块内的局部变量 t 是 main 程序块内的局部变量, 但未定义! 26
27 函数 : 命名的程序块 函数 : 函数名 参数列表 返回值 区分函数 : 函数名 参数列表 函数名 (C): 不允许同名函数 函数名 + 参数列表 (C++): 允许同名函数, 但参数列表必须不同! void swap(int& x, int& y){ int t = x; x=y; y =t } void swap(char& x, char& y){ char t = x; x=y; y =t } 27
28 函数 : 形式参数 形式参数 : 函数定义中的参数列表中的参数称为形式参数 int add(int a,int b) { return a+b; } 28
29 函数 : 形式参数 形式参数 : 函数定义中的参数列表中的参数称为形式参数 实际参数 : 调用函数时提供给该函数的参数称为实际参数 int add( int a,int b) { } return a+b; void main() { int x=3,y=4; } int z = add(x,y); 29
30 函数 : 程序堆栈 每个程序有一个自己的堆栈区, 用以维护函数之间的调用关系 int add(int a,int b) { } return a+b; void main() { int x=3,y=4; int z = add(x,y); } x=3,y=4,z main 30
31 函数 : 程序堆栈 每个程序有一个自己的堆栈区, 用以维护函数之间的调用关系 int add(int a,int b) { return a+b; } void main() { int x=3,y=4; int z = add(x,y); a=x,b=y } x=3,y=4,z add main 31
32 函数 : 程序堆栈 每个程序有一个自己的堆栈区, 用以维护函数之间的调用关系 int add(int a,int b) { } return a+b; void main() { int x=3,y=4; int z = add(x,y); } x=3,y=4,z main 32
33 函数 : 程序堆栈 每个程序有一个自己的堆栈区, 用以维护函数之间的调用关系 int add(int a,int b) { } return a+b; void main() { int x=3,y=4; int z = add(x,y); } x=3,y=4,z=7 main 33
34 函数调用 : 传值 void swap(int x,int y){ int t = x; x = y; y = t; } int main(){ int a = 3,b= 4; swap(a,b); printf( a=:%d b=:%d\n,a,b); return 0; x=a,y=b } a=3,b=4 swap main 34
35 函数调用 : 传值 void swap(int x,int y){ int t = x; x = y; y = t; } int main(){ int a = 3,b= 4; swap(a,b); printf( a=:%d b=:%d\n,a,b); return 0; x=3,y=4 } a=3,b=4 swap main 35
36 函数调用 : 传值 void swap(int x,int y){ int t = x; x = y; y = t; } int main(){ int a = 3,b= 4; swap(a,b); printf( a=:%d b=:%d\n,a,b); return 0; x=3,y=4,t=3 swap } a=3,b=4 main 36
37 函数调用 : 传值 void swap(int x,int y){ int t = x; x = y; y = t; } int main(){ int a = 3,b= 4; swap(a,b); printf( a=:%d b=:%d\n,a,b); return 0; x=4,y=4,t=3 swap } a=3,b=4 main 37
38 函数调用 : 传值 void swap(int x,int y){ int t = x; x = y; y = t; } int main(){ int a = 3,b= 4; swap(a,b); printf( a=:%d b=:%d\n,a,b); return 0; x=4,y=3,t=3 swap } a=3,b=4 main 38
39 函数调用 : 传值 void swap(int x,int y){ int t = x; x = y; y = t; } int main(){ int a = 3,b= 4; swap(a,b); printf( a=:%d b=:%d\n,a,b); return 0; } a=3,b=4 main 39
40 函数调用 : 传值 void swap(int x,int y){ int t = x; x = y; y = t; } int main(){ int a = 3,b= 4; swap(a,b); printf( a=:%d b=:%d\n,a,b); return 0; } 40
41 函数调用 : 传值 void swap(int *x,int*y){ int t = *x; *x = *y; *y = t; } int main(){ int a = 3,b= 4; swap(&a,&b); printf( a=:%d b=:%d\n,a,b); return 0; } a=3,b=4 main 41
42 函数调用 : 传值 void swap(int *x,int*y){ int t = *x; *x = *y; *y = t; } int main(){ int a = 3,b= 4; swap(&a,&b); printf( a=:%d b=:%d\n,a,b); x=&a,y=&b,t return 0; } a=3,b=4 swap main 42
43 函数调用 : 传值 void swap(int *x,int*y){ int t = *x; *x = *y; *y = t; } int main(){ int a = 3,b= 4; swap(&a,&b); printf( a=:%d b=:%d\n,a,b); x=&a,y=&b,t=3 swap return 0; } a=3,b=4 main 43
44 函数调用 : 传值 void swap(int *x,int*y){ int t = *x; *x = *y; *y = t; } int main(){ int a = 3,b= 4; swap(&a,&b); printf( a=:%d b=:%d\n,a,b); x=&a,y=&b,t=3 swap return 0; } a=4,b=4 main 44
45 函数调用 : 传值 void swap(int *x,int*y){ int t = *x; *x = *y; *y = t; } int main(){ int a = 3,b= 4; swap(&a,&b); printf( a=:%d b=:%d\n,a,b); x=&a,y=&b,t=3 swap return 0; } a=4,b=3 main 45
46 函数调用 : 传值 void swap(int *x,int*y){ int t = *x; *x = *y; *y = t; } int main(){ int a = 3,b= 4; swap(&a,&b); printf( a=:%d b=:%d\n,a,b); return 0; } a=4,b=3 main 46
47 函数调用 : 传引用 void swap(int &x,int&y){ int t = x; x = y; y = t; } x 就是 a,y 就是 b int main(){ int a = 3,b= 4; swap(a, b); printf( a=:%d b=:%d\n,a,b); x, y, t=3 swap return 0; } a=3,b=4 main 47
48 函数调用 : 传引用 void swap(int &x,int&y){ int t = x; x = y; y = t; } x 就是 a,y 就是 b int main(){ int a = 3,b= 4; swap(a, b); printf( a=:%d b=:%d\n,a,b); x, y, t=3 swap return 0; } a=4,b=4 main 48
49 函数调用 : 传引用 void swap(int &x,int&y){ int t = x; x = y; y = t; } x 就是 a,y 就是 b int main(){ int a = 3,b= 4; swap(a, b); printf( a=:%d b=:%d\n,a,b); x, y, t=3 swap return 0; } a=4,b=3 main 49
50 函数调用 : 传引用 void swap(int &x,int&y){ int t = x; x = y; y = t; } x 就是 a,y 就是 b int main(){ int a = 3,b= 4; swap(a, b); printf( a=:%d b=:%d\n,a,b); return 0; } a=4,b=3 main 50
51 函数调用 : 传引用 引用通常作为函数参数和返回值 void f(int val, int& ref){ val++; ref++; } void main(){ int x=3,y = 9; f (x, y); 3 9 printf( %d %d\n,x,y); } x y 51
52 函数调用 : 传引用 引用通常作为函数参数和返回值 void f(int val, int& ref){ val++; ref++; } void main(){ int x=3,y = 9; f (x, y); printf( %d %d\n,x,y); } val ref x y 52
53 函数调用 : 传引用 引用通常作为函数参数和返回值 void f(int val, int& ref){ val++; ref++; } void main(){ int x=3,y = 9; f (x, y); printf( %d %d\n,x,y); } val ref x y 53
54 函数调用 : 传引用 引用通常作为函数参数和返回值 void f(int val, int& ref){ val++; ref++; } void main(){ int x=3,y = 9; f (x, y); 3 10 printf( %d %d\n,x,y); } x y 54
55 函数的传值参数和传引用参数 传值参数 : 实参复制到形参 void swap(int x,int y); 引用参数 : 形参是实参的别名 void swap(int &x,int &y); 55
56 值类型与引用类型 就象不能返回局部变量的指针一样, 不能返回局部变量的引用. X& fun(x& a){ } X b; return a; // OK! return b; //bad! 56
57 变量作用域 ( 局部 全局 静态 ) 函数内部定义的变量 ( 包括函数参数 ) 称为局部变量 ( 内部变量 ), 其作用域在函数内部 局部变量随函数执行而产生, 函数结束而销毁 57
58 变量作用域 ( 局部 全局 静态 ) 函数外部定义变量称为全局变量 ( 外部变量 ), 其作用域在整个程序 程序开始执行就产生, 程序结束才销毁 C 复习 58
59 变量作用域 ( 局部 全局 静态 ) 加 static 关键字的变量称为静态变量 如果是外部变量, 则只在其所在文件里有效 ; 如果是内部变量, 则第一次初始化后就始终存在! 59
60 变量的内存分配 内存分配的三种方式 静态存储区分配 栈上创建 堆上分配 静态存储区分配 ( 固定座位 ) 内存在程序编译的时候就已经分配好, 这块内存在程序的整个运行期间都存在 例如 : 全局变量,static 变量 60
61 内存分配 栈上创建 ( 本部门的保留座位 ) 函数内部的局部变量都在栈上创建, 函数执行结束时这些内存自动被释放 栈内存分配运算内置于处理器的指令集中, 效率很高, 但是分配的内存容量有限 void foo() { int a = 1; float f = 1.0; } 这两个变量的内存, 执行到这个函数时自动分配 离开这个函数时自动释放 61
62 内存分配 栈上创建 函数内部的局部变量都在栈上创建, 函数执行结束时这些内存自动被释放 栈内存分配运算内置于处理器的指令集中, 效率很高, 但是分配的内存容量有限 void foo() { int a = 1; float f = 1.0; } 运行栈 1.0 f 1 a 62
63 内存分配 堆上分配 ( 公共座位 ) 亦称动态内存分配 程序在运行的时候用 malloc 或 new 申请任意多少的内存 程序员自己负责用 free 或 delete 释放内存 ( 否则就会出现内存泄露 ) 动态内存的生存期由程序员决定, 使用非常灵活, 但问题也最多 63
64 内存分配 int *p = (int* )malloc(10*sizeof(int)) ; p 3ab0 3ab0 64
65 内存分配 int *p = (int* )malloc(10*sizeof(int)) ; p[0]=13; p 3ab0 3ab
66 内存分配 int *p = (int* )malloc(10*sizeof(int)) ; p[0]=13; p[2]=25; p 3ab0 3ab
67 内存分配 int *p = (int* )malloc(10*sizeof(int)) ; p[0]=13; p[2]=25; *(p+2) = 28; p 3ab0 3ab
68 内存分配 int *p = (int* )malloc(10*sizeof(int)) ; p[0]=13; p[2]=25; *(p+2) = 28; // *(p+2) 等于 p[2] p 3ab0 3ab
69 内存分配 int *p = (int *)malloc(10*sizeof(int)) ; p[0]=13; p[2]=25; *(p+2) = 28; // *(p+2) 等于 p[2] free(p); p 3ab0 3ab0 69
70 内存分配 new delete int *p = (int *)malloc(10*sizeof(int)) ; //int *p = new int[10]; p[0]=13; p[2]=25; *(p+2) = 28; // *(p+2) 等于 p[2] free(p); //delete[] p; p 3ab0 3ab0 70
71 内存分配 int *p = (int* )malloc(10*sizeof(int)) ; p 3ab0 3ab0 71
72 内存分配 int *p = (int* )malloc(10*sizeof(int)) ; char *q = (char *)p; p 3ab0 3ab0 q 3ab0 72
73 内存分配 int *p = (int* )malloc(10*sizeof(int)) ; char *q = (char *)p; q[2] = A ; q[7] = B ; p 3ab0 3ab0 q 3ab0 A B 73
74 内存分配 int *p = (int* )malloc(10*sizeof(int)) ; char *q = (char *)p; q[2] = A ; q[7] = B ; P[1] = 56 p 3ab0 3ab0 q 3ab0 A 56 74
75 指针 数组 字符串 数组名就是指向数组第一个元素的指针 75
76 指针 数组 字符串 字符指针存储的是一个字符的内存地址 字符指针存储的是字符串第一个字符的内存地址 C 复习 76
77 字符串 : 结束字符 \0 结尾的字符数组 C 复习 77
78 字符串 : 结束字符 \0 结尾的字符数组 78
79 typedef 格式 typedef [ 原类型 ] [ 新类型 ]; 比如 :typedef int ElemType; 作用 定义一个新的类型叫做 [ 新类型 ], 就等价于 [ 原类型 ] 上例中, 定义了一个 ElemType 类型, 就是 int 类型 79
80 typedef 如何理解 如 : typedef int A; //A 就是 int A a; // 相当于 int a; 80
81 结构和 typedef 的结合使用 无名结构 定义结构的时候也可以不要结构名, 而用这个无名结构直接来定义变量, 比如 struct{ string name; int age; }LiMing; 这时候这个结构只有 LiMing 这一个变量, 它不可能再去定义其它变量, 因为它没有名字 81
82 结构和 typedef 的结合使用 结构和 typedef 的结合使用 例如课本 P22 有如下代码 : typedef struct{ ElemType *elem; int length; int listsize; }SqList; 红色部分就是一个无名结构 ; SqList 就是这个无名结构的别名! SqList L; // 定义了 SqList 类型的一个变量 L // 变量 L 有 3 个成员变量 //L.elem, L.length, L.listsize 82
83 结点和链表 typedef struct lnode{ double data; struct lnode *next; } LNode; 30ab0c n1 LNode n1,n2; n1.next = &n2; 30ab0c n2 83
84 程序例子 : 读写学生成绩 输入 : 一组学生成绩 ( 姓名 分数 ) 输出 : 这组学生成绩并统计及格人数 数据结构 : 定义学生类型, 用数组存储学生成绩数据 数据处理 : 键盘读入 存储 统计计算 输出 84
85 struct student typedef struct{ char name[30]; float score; } student; 85
86 student:code int main(){ student stus[100]; int i = 0,j = 0,k=0 ; do{ scanf( %s, stus[i].name); scanf( %f, &(stus[i].score)); if(stus[i].score>=60) j++; }while( i<99 && stus[i++].score>=0); for(k=0; k<i; k++){ printf( name:%s score:%3.2f\n, stus[k].name, stus[k].score); } printf( num of passed:%d\n,j); } 86
87 In_student,Out_student void In_student(student &s){ scanf( %s,s.name); } scanf( %f,&(s.score)); void Out_student(const student s){ printf( name:%s score:%3.2f\n, s.name, s.score); } 87
88 student:code2 int main(){ student stus[100]; int i = 0,j = 0,k=0 ; do{ In_student(stus[i]); if(stus[i].score>=60) j++; }while(i<99 && stus[i++].score>=0); for(k=0; k<i; k++) Out_student(stus[k]); } printf( num of passed:%d\n,j); 88
89 静态数组 : 浪费空间和空间不够 student stus[100]; 解决方法 1: 动态分配数组空间 student *stus = (student *) malloc(size*sizeof(student)); 解决方法 2: 动态分配单个 student, 并用链表串起来 L
90 动态分配数组空间 const int INITSIZE = 33; const int INC = 30; int SIZE = INITSIZE; student *stus = (student *)malloc(size 当满时 : SIZE += INC; *sizeof(student)); student * stusnew = (student *) realloc(stus,size*sizeof(student)); free(stus); // 用完后要释放空间 stus = stusnew; 90
91 student:code3 int main(){ int size = INITSIZE; int i = 0,j = 0,k=0 ; student *stus = (student *)malloc(size } *sizeof(student)); do{ if(i>=size){ student *stus_new =(student *) realloc(stus,(size+inc)*sizeof(student)); free(stus); stus = stus_new; size += INC; } In_student(stus[i]); if(stus[i].score>=60) j++; }while(stus[i++].score>=0); for(k=0;k<i;k++) Out_student(stus[k]); printf( num of passed:%d\n,j); free(stus); 91
92 链表存储 typedef struct lnode{ student data; struct lnode *next; }LNode; LNode *L; L 92
93 链表存储 : 复制 student void copy_stu(student &d, const student &s){ strcpy((char *)d.name,(char *)s.name); d.score = s.score; } 93
94 链表存储 : 初始化空的头结点 L 0 94
95 链表存储 : 头结点后插入新结点 L 0 q e 0 95
96 链表存储 : 头结点后插入新结点 L a q e 96
97 链表存储 : 遍历链表 q L a1 a2 a3 a4 97
98 int main(){ student s; int i = 0,j=0; do{in_student(s); if(s.score>=60) j++; else if(s.score<0) break; }while(s.score>=0); } printf( num of passed:%d\n,j); 98
99 建议用 vs201x 环境 1) new->project->visual C++ -> Win32 Console Application 输入一个工程名, 如 myfirst 99
100 建议用 vs201x 环境 2)next, 取消 Precompiled Header 前面的勾, 勾上 Empty Project 前的勾. 点 Finish 完成 100
101 建议用 vs201x 环境 3) 同样方法生成一个.cpp 文件, 如 myfirst.cpp 并加入到该工程中. 101
102 建议用 vs201x 环境 3) 同样方法生成一个.cpp 文件, 如 myfirst.cpp 并加入到该工程中. 右键菜单 102
103 建议用 vs201x 环境 3) 同样方法生成一个.cpp 文件, 如 myfirst.cpp 并加入到该工程中. 103
104 建议用 vs201x 环境 5) 输入程序代码 104
105 建议用 vs201x 环境 5) 然后按 CTRL+F7 编译源代码或按 F7 build 该工程, 再按 CTRL+F5 执行. 105
106 C++ 输入输出流 输出流运算符 106
107 C++ 输入输出流 输入流运算符 107
108 C++ 输入输出流 #include <iostream> using std::cin; using std::cout; int main(){ int x; double y; cin>>x>>y; cout<<x<< <<y<< \n ; return 0; } 包含头文件 声明输入流对象 声明输出流对象 108
109 C++ 输入输出流 #include <fstream> using std::ifstream; int main(){ } ifstream ifile( a.txt ); if(!ifile) return -1; double x,y,z; while(ifile>>x){ } ifile>>y>>z; std::cout<<x<< <<y << <<z<< \n ; return 0; a.txt
110 C++ 中的 string C++ 中的类是一种用户定义类型, 类似于 C 语言中的结构类型 比如 string 就是 C++ 的一个类 C++ 中的类是对 C 语言的结构 struct 的扩展, 除 数据成员外, 还包括函数成员 ( 也称成员函数 ) 110
111 源文件和程序 大的程序经常被分成多个文件 编译器对每个源文件进行编译 连接器将编译好的目标文件和相关的库等连接成可执行文件 单一定义规则 : 任何变量 函数等只能定义一次, 但可被声明多次 可能被多次引用的声明通常放在头文件中 111
112 源文件和程序 Math.h #ifndef MATH_H_$# #define MATH_H_$# int add(int,int); extern int PI; double CirArea(double); #endif Math.cpp #include Math.h int PI = ; int add(int a,int b) { return a+b;} double CirArea(double r){ } return PI*r*r; 112
113 源文件和程序 main.cpp #include Math.h #include <iostream> using namespace std; int main(){ double r,a; cin>>r; A = CirArea(r); cout<<a<< \n ; return 0; } Preprocessor Inlines #includes etc. Compiler Translates to machine code Associates calls with functions Linker Associates functions with definitions Executable External Libraries 113
114 作业 1. 编程实现不同版本的学生成绩表程序. 2. 搞懂幻灯片中的语法点, 并编写代码比较验证这些语法点 ( 变量作用域 结构 指针 数组, 函数参数传递 引用 cin/cout/string 等 ). 写一个关于重要语法点的学习报告. 114
115 Download CodeBlocks 115
116 Download visual studio community 116
Microsoft PowerPoint - 5. 指针Pointers.ppt [兼容模式]
指针 Pointers 变量指针与指针变量 Pointer of a variable 变量与内存 (Variables and Memory) 当你声明一个变量时, 计算机将给该变量一个内存, 可以存储变量的值 当你使用变量时, 计算机将做两步操作 : - 根据变量名查找其对应的地址 ; - 通过地址对该地址的变量内容进行读 (retrieve) 或写 (set) 变量的地址称为变量的指针! C++
More informationMicrosoft PowerPoint - 3. 函数Functionl.ppt [兼容模式]
函数 Function 如何重用代码 How to reuse code 3 4 = 3*3*3*3 3 4,6 5 : 拷贝 - 粘帖代码 (Copy-paste code) 3 4,6 5,12 10 : 拷贝 - 粘帖代码 (Copy-paste code) Bad! 使用函数 (with a function) 使用函数 (with a function) 使用函数 (with a function)
More informationchap07.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 informationFY.DOC
高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主
More informationCC213
: (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 informationC++ 程序设计 告别 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新版 明解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没有幻灯片标题
指针作为函数参数 : 原因 : 1 需要修改一个或多个值,( 用 return 语句不能解决问题 ) 2 执行效率的角度 使用方法 : 在函数原型以及函数首部中需要声明能够接受指针值的形参, 具体的写法为 : 数据类型 * 形参名 如果有多个指针型形参, 则用逗号分隔, 例如 : void swap(int *p1, int *p2) 它说明了形参 p1 p2 是指向整型变量的指针 在函数调用时,
More informationMicrosoft PowerPoint - 4. 数组和字符串Arrays and Strings.ppt [兼容模式]
Arrays and Strings 存储同类型的多个元素 Store multi elements of the same type 数组 (array) 存储固定数目的同类型元素 如整型数组存储的是一组整数, 字符数组存储的是一组字符 数组的大小称为数组的尺度 (dimension). 定义格式 : type arrayname[dimension]; 如声明 4 个元素的整型数组 :intarr[4];
More informationMicrosoft PowerPoint - 1. C++介绍.ppt [兼容模式]
C++ 入门 http://hwdong.com 1. 程序 = 数据 + 运算 Application = Data + Operator 程序就是对数据进行加工处理 ( 运算 ) 程序 = 数据 + 运算 数据用变量 ( 常量 ) 表示, 用运算符对它们进行运算 程序 = 变量 + 运算符 程序中的数据应有条理地存储在内存中, 处理需要按照一定步骤或方法进行 程序 = 数据结构 + 算法 机器语言
More information新・解きながら学ぶ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 informationuntitled
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 informationOOP 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新・明解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 informationC/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 informationGenerated 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言語入門編
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 informationnooog
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语言程序设计》第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 informationC++ 程序设计 告别 OJ2 - 参考答案 MASTER 2019 年 5 月 3 日 1
C++ 程序设计 告别 OJ2 - 参考答案 MASTER 2019 年 5 月 3 日 1 1 TEMPLATE 1 Template 描述 使用模板函数求最大值 使用如下 main 函数对程序进行测试 int main() { double a, b; cin >> a >> b; cout c >> d; cout
More information《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 informationC/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 information2013 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 informationuntitled
不 料 料 例 : ( 料 ) 串 度 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 informationuntitled
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试卷代号 :1075 座位号 rn 国家开放大学 ( 中央广播电视大学 )2015 年秋季学期 " 开放本科 " 期末考试 c+ 十语言程序设计试题 2016 年 1 月 t 问一 Urr-f 斗 士 1 1. 下面的保留字 ( ) 不能作为函数的返回类型 A. void B. int C. new
试卷代号 :1075 座位号 rn 国家开放大学 ( 中央广播电视大学 )2015 年秋季学期 " 开放本科 " 期末考试 c+ 十语言程序设计试题 2016 年 1 月 t 问一 Urr-f 斗 士 1 1. 下面的保留字 ( ) 不能作为函数的返回类型 A. void B. int C. new D. long 2. 在每个 C 十 + 程序中都必须包含有这样一个函数, 该函数的函数名为 ) A.main
More informationMicrosoft PowerPoint - 10 模板 Template.pptx
模板 Tempalte 泛型编程的需要 Why Templates? 设想你对整数类型实现了一个排序算法 : void sort(int *is,int n); 用该函数可以对实 复数或工资单排序吗? 模板可以复用源代码 - 泛型编程. inline void Swap( int &x, int &y){ int t = x; x = y; y =t; inline void Swap(double
More informationint *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 informationOOP with Java 通知 Project 4: 4 月 18 日晚 9 点 关于抄袭 没有分数
OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 4: 4 月 18 日晚 9 点 关于抄袭 没有分数 复习 类的复用 组合 (composition): has-a 关系 class MyType { public int i; public double d; public char c; public void set(double
More information02
Thinking in C++: Volume One: Introduction to Standard C++, Second Edition & Volume Two: Practical Programming C++ C C++ C++ 3 3 C C class C++ C++ C++ C++ string vector 2.1 interpreter compiler 2.1.1 BASIC
More informationC/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试卷代号 ~1075 座位号 E 口 国家开放大学 ( 中央广播电视大学 )20]5 年秋季学期 " 开放本科 " 期末考试 C 十十语言程序设计 试题 同二二十斗 2016 年 1 月 巴叫一 1. 下面的保留字 ( ) 不能作为函数的返回类型 A. void B. int C. new D. l
试卷代号 ~1075 座位号 E 口 国家开放大学 ( 中央广播电视大学 )20]5 年秋季学期 " 开放本科 " 期末考试 C 十十语言程序设计 试题 同二二十斗 2016 年 1 月 巴叫一 1. 下面的保留字 ( ) 不能作为函数的返回类型 A. void B. int C. new D. long 2. 在每个 c++ 程序中都必须包含有这样一个函数, 该函数的函数名为 ( ) A. main
More informationMicrosoft PowerPoint - string_kruse [兼容模式]
Strings Strings in C not encapsulated Every C-string has type char *. Hence, a C-string references an address in memory, the first of a contiguous set of bytes that store the characters making up the string.
More information立 志 于 打 造 最 贴 近 考 生 实 际 的 辅 导 书 计 算 机 考 研 之 数 据 结 构 高 分 笔 记 率 辉 编 著 周 伟 张 浩 审 核 讨 论 群 :15945769
立 志 于 打 造 最 贴 近 考 生 实 际 的 辅 导 书 计 算 机 考 研 之 数 据 结 构 高 分 笔 记 率 辉 编 著 周 伟 张 浩 审 核 讨 论 群 :15945769 前 言 在 计 算 机 统 考 的 四 门 专 业 课 中, 最 难 拿 高 分 的 就 是 数 据 结 构 但 是 这 门 课 本 身 的 难 度 并 不 是 考 生 最 大 的 障 碍, 真 正 的 障 碍
More informationC/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 informationMicrosoft 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_汪_文前新ok[3.1].doc
普 通 高 校 本 科 计 算 机 专 业 特 色 教 材 精 选 四 川 大 学 计 算 机 学 院 国 家 示 范 性 软 件 学 院 精 品 课 程 基 金 青 年 基 金 资 助 项 目 C 语 言 程 序 设 计 (C99 版 ) 陈 良 银 游 洪 跃 李 旭 伟 主 编 李 志 蜀 唐 宁 九 李 涛 主 审 清 华 大 学 出 版 社 北 京 i 内 容 简 介 本 教 材 面 向
More informationC 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 informationC/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幻灯片 1
第一课 C 与 C++ 互联网新技术在线教育领航者 1 内容概述 第一部分 : C++ 综述 1. C++ 历史背景 2. Why C++ 3. 推荐书籍第二部分 : C VS C++ 1. C 语法回顾 2. 例 :C 实现动态数组 3. C++ 的 vector 第三部分 :C++ 对 C 的扩展 ( 上 ) 1. 命名空间 2. 输入输出 3. 基本类型转换 4. 声明 列表初始化 5. 指针和引用
More informationエスポラージュ株式会社 住所 : 東京都江東区大島 東急ドエルアルス大島 HP: ******************* * 关于 Java 测试试题 ******
******************* * 关于 Java 测试试题 ******************* 問 1 运行下面的程序, 选出一个正确的运行结果 public class Sample { public static void main(string[] args) { int[] test = { 1, 2, 3, 4, 5 ; for(int i = 1 ; i System.out.print(test[i]);
More informationC 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 informationMicrosoft PowerPoint - 8. 运算符重载 Operator Overloading.pptx
运算符重载 Operator Overloading class Point { public: ; double x_, y_; Why Operator Overloading? Point (double x =0, double y = 0):x_(x),y_(y) { int main(){ Point a(1., 2), b(3,4); Point c = a + b; return 0;
More informationMicrosoft PowerPoint - 01_Introduction.ppt
Hello, World C 程序设计语言 第 1 章章观其大略 孙志岗 sun@hit.edu.cn http://sunner.cn prf("hello,, world\n"); 超级无敌考考你 : 如何把 hello 和 world 分别打印在两行? 2004-12-19 A Tutorial Introduction 2 hello.c 打印华氏温度与摄氏温度对照表 计算公式 : C=(5/9)(
More informationuntitled
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 informationOOP with Java 通知 Project 2 提交时间 : 3 月 21 日晚 9 点 作业提交格式 学习使用 文本编辑器 cmd, PowerShell (Windows), terminal(linux, Mac)
OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 2 提交时间 : 3 月 21 日晚 9 点 作业提交格式 学习使用 文本编辑器 cmd, PowerShell (Windows), terminal(linux, Mac) 复习 面向对象编程 将实际问题分解成不同的对象 不的对象提供不同的服务 对象之间可以传递消息 例子小李深夜
More informationebook50-15
15 82 C / C + + Developer Studio M F C C C + + 83 C / C + + M F C D L L D L L 84 M F C MFC DLL M F C 85 MFC DLL 15.1 82 C/C++ C C + + D L L M F C M F C 84 Developer Studio S t u d i o 292 C _ c p l u s
More informationOOP with Java 通知 Project 4: 4 月 19 日晚 9 点
OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 4: 4 月 19 日晚 9 点 复习 类的复用 组合 (composition): has-a 关系 class MyType { public int i; public double d; public char c; public void set(double x) { d
More informationC++ 程式設計
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 informationC/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一 关于内存 数据存储 变量分类 局部变量 全局变量 静态变量 请看下面代码, 分析变量类型? int pi = 3; int Area(int r, int *sum) { int b; static int c =0; b = pi * r * r; c += b; *sum = c; retu
移动平台应用软件开发 C/C++/JAVA 基础 指针以及指针操作 主讲 : 张齐勋 zhangqx@ss.pku.edu.cn 移动平台应用软件开发 课程建设小组北京大学二零一五年 一 关于内存 数据存储 变量分类 局部变量 全局变量 静态变量 请看下面代码, 分析变量类型? int pi = 3; int Area(int r, int *sum) { int b; static int c =0;
More informationMicrosoft 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
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 informationNOWOER.OM m/n m/=n m/n m%=n m%n m%=n m%n m/=n 4. enum string x1, x2, x3=10, x4, x5, x; 函数外部问 x 等于什么? 随机值 5. unsigned char *p1; unsigned long *p
NOWOER.OM /++ 程师能 评估. 单项选择题 1. 下 描述正确的是 int *p1 = new int[10]; int *p2 = new int[10](); p1 和 p2 申请的空间 的值都是随机值 p1 和 p2 申请的空间 的值都已经初始化 p1 申请的空间 的值是随机值,p2 申请的空间 的值已经初始化 p1 申请的空间 的值已经初始化,p2 申请的空间 的值是随机值 2.
More informationuntitled
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 informationMicrosoft 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 information6 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网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( 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 informationMicrosoft Word - 《C语言开发入门》课程教学大纲-2.doc
C 语言开发入门 课程教学大纲 ( 课程英文名称 ) 课程编号 :201409210011 学分 :5 学分学时 :60 学时 ( 其中 : 讲课学时 :37 学时上机学时 :23 学时 ) 先修课程 : 计算机导论后续课程 :C++ 程序设计适用专业 : 信息及其计算机相关专业开课部门 : 计算机系 一 课程的性质与目标 C 语言开发入门 是计算机各专业必修的基础课程, 是数据结构 C++ Java
More informationC 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 informationMicrosoft 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试卷代号 :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<4D F736F F D205A572D2D A1AAA1AAD4ACE7F42D43D3EFD1D4CAB5D1B5BDCCB3CC2E646F6378>
第 1 部分 Visual Studio 6.0 开发环境介绍 本书以 Visual C++ 6.0 作为 C 源程序的实践开发环境, 本章将首先介绍 Visual C++ 6.0 环境的基本操作, 包括 Visual C++ 6.0 的安装和启动,C 源程序的编辑 运行与调试 1.1 安装与启动 Visual C++ 6.0 MSDN Visual C++ 6.0 1.1 Microsoft Visual
More information《计算概论》课程 第十九讲 C 程序设计语言应用
计算概论 A 程序设计部分 字符数组与字符串 李戈 北京大学信息科学技术学院软件研究所 lige@sei.pku.edu.cn 字符数组的定义 #include int main() char a[10] = 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' ; for (int i = 0; i < 10; i++) cout
More information第3章.doc
3 3 3 3.1 3 IT Trend C++ Java SAP Advantech ERPCRM C++ C++ Synopsys C++ NEC C C++PHP C++Java C++Java VIA C++ 3COM C++ SPSS C++ Sybase C++LinuxUNIX Motorola C++ IBM C++Java Oracle Java HP C++ C++ Yahoo
More informationChapter12 Derived Classes
继 承 -- 派 生 类 复 习 1. 有 下 面 类 的 说 明, 有 错 误 的 语 句 是 : class X { A) const int a; B) X(); C) X(int val) {a=2 D) ~X(); 答 案 :C 不 正 确, 应 改 成 X(int val) : a(2) { 2. 下 列 静 态 数 据 成 员 的 特 性 中, 错 误 的 是 A) 说 明 静 态 数
More informationC 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 informationC/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 informationuntitled
1 7 7.1 7.2 7.3 7.4 7.5 2 7.1 VFT virtual 7.1 3 1 1. 2. public protected public 3. VFT 4. this const volatile 4 2 5. ( ) ( ) 7.1 6. no-static virtual 7.2 7. inline 7.3 5 3 8. this this 9. ( ) ( ) delete
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概述
OPC Version 1.6 build 0910 KOSRDK Knight OPC Server Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOS_Init...5 2.2.2 KOS_InitB...5 2.2.3
More informationMicrosoft Word - CPE考生使用手冊160524.docx
大 學 程 式 能 力 檢 定 (CPE) 考 生 使 用 手 冊 2016 年 5 月 24 日 這 份 手 冊 提 供 給 參 加 CPE 檢 定 考 試 的 考 生 內 容 包 含 考 試 環 境 的 使 用, 以 及 解 題 時 所 使 用 I/O 的 基 本 知 識 1. 如 欲 報 名 參 加 CPE 考 試, 請 先 於 CPE 網 站 完 成 帳 號 註 冊, 然 後 再 報 名 該
More informationC/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 informationCHAPTER VC#
1. 2. 3. 4. CHAPTER 2-1 2-2 2-3 2-4 VC# 2-5 2-6 2-7 2-8 Visual C# 2008 2-1 Visual C# 0~100 (-32768~+32767) 2 4 VC# (Overflow) 2-1 2-2 2-1 2-1.1 2-1 1 10 10!(1 10) 2-3 Visual C# 2008 10! 32767 short( )
More information北京大学
1 string 类 郭炜刘家瑛 北京大学程序设计实习 string 类 string 类是一个模板类, 它的定义如下 : typedef basic_string string; 使用 string 类要包含头文件 string 对象的初始化 : string s1("hello"); // 一个参数的构造函数 string s2(8, x ); // 两个参数的构造函数
More information2013 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 informationPowerPoint 演示文稿
第 1 章程序设计和 C 语言 1.1 什么是计算机程序 1.2 什么是计算机语言 1.3 C 语言的发展及其特点 1.4 最简单的 C 语言程序 1.5 运行 C 程序的步骤与方法 1.6 程序设计的任务 1.1 什么是计算机程序 程序 : 一组计算机能识别和执行的指令 只要让计算机执行这个程序, 计算机就会自动地 有条不紊地进行工作 计算机的一切操作都是由程序控制的, 离开程序, 计算机将一事无成
More information2015年计算机二级(C语言)模拟试题及答案(四)
2016 年 计 算 机 二 级 (C 语 言 ) 模 拟 试 题 及 答 案 (4) 一 填 空 题 1 C 语 言 中 基 本 的 数 据 类 型 有 : 2 C 语 言 中 普 通 整 型 变 量 的 类 型 说 明 符 为, 在 内 存 中 占 字 节, 有 符 号 普 通 整 型 的 数 据 范 围 是 3 整 数 -35 在 机 内 的 补 码 表 示 为 4 执 行 下 列 语 句 int
More informationuntitled
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 informationEK-STM32F
STMEVKIT-STM32F10xx8 软 件 开 发 入 门 指 南 目 录 1 EWARM 安 装... 1 1.1 第 一 步 : 在 线 注 册... 1 1.2 第 二 步 : 下 载 软 件... 2 1.3 第 三 步 : 安 装 EWARM... 3 2 基 于 STMEVKIT-STM32F10xx8 的 示 例 代 码 运 行... 6 2.1 GPIO Demo... 6 2.2
More information2015年计算机二级(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 informationMicrosoft Word - 第3章.doc
在第 2 章中已经对 C 语言变量的声明 定义及初始化进行了介绍, 并简单介绍了 C 语言变量的作用域, 本章将对变量的存储方式进行详细的介绍, 不同存储方式的变量有不同的生命期, 作用域也各不相同 通过对 C 语言变量存储方式的介绍, 使更加深入的了解 C 语言变量的作用域的工作原理 本章讲述的知识点包括 : C 语言变量的生存期和作用域 ; C 语言局部变量与全局变量 ; C 语言变量的存储方式
More informationMicrosoft Word - 第3章.doc
第 3 章流程控制和数组 3.1 实验目的 (1) 熟练掌握控制台应用程序的代码编写和调试, 以及运行方法 (2) 掌握选择结构的一般语法格式和应用 (3) 掌握 switch 语句的用法 (4) 掌握选择结构的嵌套的用法, 能灵活使用选择结构解决实际问题 (5) 掌握 while 循环语句的一般语法格式 (6) 掌握 for 循环语句的一般语法格式 (7) 掌握循环嵌套的语法格式 (8) 掌握一维数组的定义
More informationWHUST 2017 Div.2 Day 3.5 C++ 标准模版库
标准模版库 标准模版库 集训队郭松 集训队郭松 标准模版库 标准模版库 纲 介绍算法竞赛中, 需要 到的 知识命名空间代码框架实参 类型模版函数简介 模版类简介 集训队郭松 标准模版库 标准模版库介绍算法竞赛中, 需要 到的 知识算法竞赛中, 需要 到的 知识标准命名空间 std 集训队郭松 标准模版库 标准模版库介绍算法竞赛中, 需要 到的 知识算法竞赛中, 需要 到的 知识标准命名空间 std
More informationuntitled
MPICH anzhulin@sohu.com 1 MPICH for Microsoft Windows 1.1 MPICH for Microsoft Windows Windows NT4/2000/XP Professional Server Windows 95/98 TCP/IP MPICH MS VC++ 6.x MS VC++.NET Compaq Visual Fortran 6.x
More information1 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<4D F736F F D E4345C6BDCCA84323B1E0B3CCD2AAB5E3D6AED2BB2E646F63>
基于 WINCE 平台 C# 编程要点之一 本文主要介绍在基于 Windows CE 平台的英创嵌入式主板下进行 C#(Microsoft Visual Stdio.Net 2005) 应用程序开发时会常常用到的一些功能函数以及开发方法, 这些方法适用于英创采用 WinCE 平台的所有型号嵌入式主板, 包括 EM9000 EM9260 EM9160 等 本文要点包括 : 文件的删除和复制 如何获取存取设备的空间大小
More informationMicrosoft PowerPoint - 06_Struct.ppt
C 程序设计语言 第 6 章章结构 孙志岗 sun@hit.edu.cn http://sunner.cn 从基本数据类型 复合数据类型到抽象数据类型 类型本不存在 内存里存储的内容, 你认为它是什么, 它就是什么 高级语言设计了基本数据类型 : 整型 浮点型 字符型等 不同的语言也会定义不同的基本类型 基本数据类型并不能方便地解决所有问题 复合数据类型是基本数据类型迭代派生而来 典型的代表就是 结构,,
More informationMicrosoft Word - 01.DOC
第 1 章 JavaScript 简 介 JavaScript 是 NetScape 公 司 为 Navigator 浏 览 器 开 发 的, 是 写 在 HTML 文 件 中 的 一 种 脚 本 语 言, 能 实 现 网 页 内 容 的 交 互 显 示 当 用 户 在 客 户 端 显 示 该 网 页 时, 浏 览 器 就 会 执 行 JavaScript 程 序, 用 户 通 过 交 互 式 的
More informationuntitled
1 2 3 4 5 6 2005 30 28 36 29 19 33 6 58 1 1 2. 3 1 2 4 5 6 7 8 58 2 30 30 1 01 58 3 2 1 2 3 1 2 3 4 5 58 4 6 7 8 1 9 10 11 12 13 14 15 16 17 18 19 20 1 ( 1 ) 21 22 23 24 25 26 58 5 27 28 29 30 31 32 33
More informationPs22Pdf
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 informationC/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 informationC++ 程序设计 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1
C++ 程序设计 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1 1 CIRCLE 1 Circle 描述 编写一个圆类 Circle, 实现半径的输入 面积的计算和输出 输入 圆的半径 (double 类型 ) 输出 圆的面积 ( 保留小数点后两位 ) 样例输入 3 样例输出 28.27 提示 圆周率的取值需要比较精确, 以保证计算结果的精度 #include
More informationC++ 程序设计 实验 3 - 参考答案 MASTER 2017 年 5 月 21 日 1
C++ 程序设计 实验 3 - 参考答案 MASTER 2017 年 5 月 21 日 1 1 圆 1 圆 设计圆类 包含 包含基本属性和基本属性访问接口 计算面积和周长接口 2 1 圆 1 #include 2 using namespace std ; 3 c l a s s CCircle 4 { 5 p r i v a t e : 6 double r ; 7 const
More informationC++ 程序设计 OJ2 - 参考答案 MASTER 2019 年 5 月 3 日 1
C++ 程序设计 OJ2 - 参考答案 MASTER 2019 年 5 月 3 日 1 1 PERSON 1 Person 题目描述 编写程序, 定义一个基类 Person, 包含 name 和 age 两个数据成员 ; 再由它派生出学生类 Student 和教师类 Teacher, 其中学生类添加学号 no 数据, 教师类添加职称 title 数据 ; 要求每个类均有构造函数 析构函数和显示数据的函数
More informationMicrosoft Word - 11.doc
除 錯 技 巧 您 將 於 本 章 學 到 以 下 各 項 : 如 何 在 Visual C++ 2010 的 除 錯 工 具 控 制 下 執 行 程 式? 如 何 逐 步 地 執 行 程 式 的 敘 述? 如 何 監 看 或 改 變 程 式 中 的 變 數 值? 如 何 監 看 程 式 中 計 算 式 的 值? 何 謂 Call Stack? 何 謂 診 斷 器 (assertion)? 如 何
More informationCHAPTER 1
CHAPTER 1 1-1 System Development Life Cycle; SDLC SDLC Waterfall Model Shelly 1995 1. Preliminary Investigation 2. System Analysis 3. System Design 4. System Development 5. System Implementation and Evaluation
More informationOOP with Java 通知 Project 4: 5 月 2 日晚 9 点
OOP with Java Yuanbin Wu cs@ecnu OOP with Java 通知 Project 4: 5 月 2 日晚 9 点 复习 类的复用 组合 (composition): has-a 关系 class MyType { public int i; public double d; public char c; public void set(double x) { d =
More information