笔记
学编程的小小只
这个作者很懒,什么都没留下…
展开
-
C语言实训周笔记(10)
const基础知识int a=10,b=20;int *p=&a;*p=100; //可以改p=&b; //可以改const int*cp=&a;*cp=100; //*cp不可以改;cp=&b; //cp可以改;int * const s = &a;*s=100; //可以改;s=&b; ..原创 2021-07-09 16:10:11 · 67 阅读 · 0 评论 -
C语言实训周笔记(9)
函数重载:函数名相同,形参列表不同,我们就称为函数重载;编译器在编译时起了个新名字,编译器内部有名字粉碎技术; int Max(int a, int b)//H { return a > b ? a : b; } char Max(char a, char b)//D { return a > b ? a : b; } double Max(double a, double b)//N { return a > b ? a : b; }ne.原创 2021-07-09 16:02:38 · 78 阅读 · 0 评论 -
C语言实训周笔记(8)
缺省函数主要包括:拷贝构造函数、析构函数、构造函数、赋值语句构造函数:创建对象,并对对象初始化;有返回值析构函数:释放;有返回值;对于面向对象来说:空间与对象是分离的;#include <iostream>#include <stdlib.h>#include <stdio.h>#include <string.h>using namespace std;template<class Type>class SeqStack原创 2021-07-08 18:20:35 · 119 阅读 · 0 评论 -
C语言实训周笔记(7)
面向对象编程:class CGoods{public: char Name[20]; int Amount; float Price; float Total_value;};在上述语句的基础上需要:CGoods c1; this=>&c1;CGoods *this; *this=>c2;this=&c1; (*this).Price=10;c1.Price=10...原创 2021-07-08 18:11:47 · 137 阅读 · 0 评论 -
C语言实训周笔记(6)
C语言基本实现扫雷游戏:#include<stdio.h>#include<stdlib.h> // rand#define INITSHOW 0x80 // 1000 0000 // 宏定义#define MAKEMINE 0x40 // 0100 0000 // 宏定义#define MINESHOW 0x20 // 0010 0000 // 宏定义#define MAKESUM 0x10 // 0001 0000 // 宏定义#define PRIN原创 2021-07-07 19:43:05 · 79 阅读 · 0 评论 -
C语言实训周笔记(5)
(1)全局变量和局部变量:全局变量作用域是整个程序,包含所有源文件,位于数据区;局部变量的作用域仅限于函数内部,位于栈区。(2)一个字节占8个二进制位;(3)C语言32个关键词:数据类型关键字(12个):char、double、enum、float、int、long、short、signed、struct、union、unsigned、void控制语句关键字(12个):循环: for、do、while、break、continue条件:if、else、goto开关:s原创 2021-07-07 19:40:21 · 128 阅读 · 0 评论 -
C语言实训周笔记(4)
查表函数的应用:int FindValue(int* br, int n, int val)//index:-1{ assert(br != NULL); for (int i = 0; i < n; ++i) { if (br[i] == val) { return i; } else { return -1; } }}冒泡排序法:知识模块:swap()函数、for循环、数组应用思想基础:(1)比较相邻的元素,如果这个元素大就往后原创 2021-07-06 21:43:00 · 95 阅读 · 0 评论 -
C语言实训周笔记(3)
1、C语言swap函数的正确使用:方法一(地址):void swap(int &a,int &b){Int temp;temp=a;a=b;b=temp;}方法二(指针):void swap(int*a,int*b){int temp;temp=*a;*a=*b;*b=temp;}2.C语言中进制的转换思想:int main(){ int a = 10; int b = 010; int c = 0x10; int d =原创 2021-07-06 21:27:51 · 114 阅读 · 0 评论 -
C语言实训周笔记(2)
#include <iostream>#include <assert.h>using namespace std;Void Print(int br[10])void Print_Ar(int* br, int n){ for (int i = 0; i < n; ++i) { printf("%d", br[i]); } printf("\n");}//1..100void Init_Ar(int* br, int n){ assert(.原创 2021-07-06 21:02:46 · 146 阅读 · 0 评论 -
C语言实训周课堂笔记(1)
C语言基本数据类型:short、int、long、char、float、double这六个关键字代表C语言中六种基本数据类型,在不同的系统上,这些类型占据的字节也是不同的,具体可用sizeof进行测试,如下:#include <iostream>using namespace std;int main(){cout<<"char size:"<<sizeof(char)<<endl;cout<<"short si...原创 2021-07-06 20:39:48 · 208 阅读 · 0 评论