自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(83)
  • 收藏
  • 关注

原创 有C基础学习C++第九天(类和对象-对象特性)

1.构造函数和析构函数。2.构造函数的分类与调用。3.浅拷贝与深拷贝。4.静态成员变量。5.静态成员函数。6.成员变量和成员函数分开存储。7.this指针的用途。8.空指针访问成员函数。9.const修饰成员函数。

2022-12-21 13:47:57 129

原创 有C基础学习C++第八天(类和对象-封装)

1.创建类,属性,行为。2.3种访问权限,公共权限 public ,保护权限 protected,私有权限 private。3.class和struct 的区别。4.成员属性私有化。5.点和圆关系案例。

2022-12-18 20:54:25 135

原创 有C基础学习C++第七天(函数其他细节)

1.函数默认参数2.函数的占用参数3.函数重载

2022-12-18 16:20:09 114

原创 有C基础学习C++第六天(引用)

1.引用做函数参数(1.值传递,2.地址传递,3.引用传递)2.引用做函数返回值。3.引用的本质在C++内部中是一个指针常量。

2022-12-18 15:35:58 98

原创 有c基础学习C++第五天(内存模型,栈区,堆区)

栈区,堆区将数据开辟到堆区,利用关键字new。放堆区的数据,利用关键字 delete。

2022-12-17 19:38:25 117

原创 有C基础学习C++第四天(结构体)

1.结构体数组2.结构体指针3.结构体嵌套4.结构体做函数参数

2022-12-17 17:24:22 55

原创 有C基础学习C++第三天(指针)

1.定义指针2.使用指针3.指针占用内存空间都是4个字节4.const修饰指针 常量指针5.const修饰常量 指针常量6.const修饰指针和常量7.数组指针8.指针和函数:9.案例:封装一个函数,利用冒泡排序,实现对整数型数组的升序排列

2022-12-16 20:35:23 246

原创 有C基础学C++第二天(数组,函数)

1.一维数组,二维数组,查看占用内存空间,查看元素个数,查看地址。2.函数4种常见样式:1.无参无返,2.有参无返,3.无参有返,4.有参有返。3.函数声明:要想把函数写在main函数的后面,得提前对函数声明,告诉编译器函数的存在,函数的声明可以有多次,但定义只能有一次。

2022-12-16 14:22:38 71

原创 有C基础学习C++第一天(基础语法)

1.输入的代码与c不同,c:printf;2.科学计数法3.C风格字符串,用数组,不能用string4.c++的输入5.++x, x++6.continue语句, break语句7.goto语句

2022-12-15 19:22:33 180

原创 C语言第31天,动态内存分配(一),malloc,free,calloc,realloc函数初识

mallocfree#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>#include<errno.h>#include<string.h>//malloc free//malloc函数向内存申请一块连续可用的空间,并返回指向这块空间的指针。//如果开辟失败,则返回一个NULL指针,因此malloc的返回值一定要做检查//返回值的类型是void*,所

2021-08-04 22:12:14 115

原创 C语言第30天,实现通讯录的增删改查

头文件 contact.h#define _CRT_SECURE_NO_WARNINGS#define MAX 1000#define MAX_NAME 20#define MAX_SEX 5#define MAX_TELE 12#define MAX_ADDR 30#include<stdio.h>#include<string.h>struct PeoInfo { char name[MAX_NAME]; int age; char sex[MAX_

2021-08-03 21:48:23 176

原创 C语言第29天,结构体位段,枚举,联合

结构体位段#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>//结构体位段struct S { int a : 2; int b : 5; int c : 10; int d : 30;};int main() { struct S s; printf("%d\n", sizeof(s));//8 return 0;}

2021-08-02 17:04:13 74

原创 C语言第28天,结构体进阶,嵌套初始化,内存对齐,传参

结构体全局变量,局部变量#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>struct Stu { char name[20]; char tele[12]; char sex[10]; int age;}s4, s5, s6;//s4,s5,s6 - 全局变量struct Stu s3;//全局变量int main() { struct Stu s1; struct Stu s2;//s1,s2 - 局部变量 re

2021-07-31 21:20:49 102

原创 C语言第28天,字符函数和内存函数的使用与剖析

字符函数#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <string.h>#include <ctype.h>//字符分类函数int main() { char ch = 'w'; int ret = islower(ch);//判断是否是小写字母 printf("%d\n", ret);//2 int ret2 = isdigit(ch);//判断是否是数字 printf(

2021-07-31 18:16:16 63

原创 C语言第28天,字符串使用与剖析(二),strstr,strtok,strerror

strstr - 查找子字符串#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <string.h>//strstr - 查找子字符串char* my_strstr(const char* p1, const char* p2) { char* s1 = NULL; char* s2 = NULL; char* cur = (char*)p1; if (*p2 == '\0') { retu

2021-07-31 13:39:55 75

原创 C语言第27天,字符串函数使用与剖析(一),strlen,strcpy,strcat,strcmp,strncpy,strncat,strcmp

strlen - 求字符串长度#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <string.h>//strlen - 求字符串长度//字符串以'\0'作为结束标志,strlen函数返回的是在字符串中'\0'前面出现的字符个数(不包含'\0')//参数指向的字符串必须要以'\0'结束//注意函数的返回值为size_t,是无符号的int my_strlen(char* str) { int co

2021-07-29 21:32:08 86

原创 杨氏矩阵查找数字

杨氏矩阵查找数字#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>//杨氏矩阵查找数字int FindNum(int arr[3][3], int k, int row, int col) { int x = 0; int y = col - 1; while (x <= row - 1 && y >= 0) { if (arr[x][y] > k) { y--; } else

2021-07-28 16:37:57 70

原创 C语言第26天,练习题,旋转字符串 || 判断一个字符串是否为另一个字符串旋转后得到的

旋转字符串#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <string.h>//旋转字符串//1.暴力求解法void left_move(char* arr, int k) { int i = 0; int len = strlen(arr); for (i = 0; i < k; i++) { //左旋转一个字符 char tmp = *arr; int j = 0;

2021-07-27 19:53:28 114

原创 C语言第25天,练习题,杨辉三角

unsigned#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>int main() { unsigned char a = 200;//无符整型 unsigned char b = 100; unsigned char c = 0; c = a + b;//整型提升 printf("%d %d", a + b, c);//300,44} #define _CRT_SECURE_NO_WARNINGS#include

2021-07-26 20:32:06 153

原创 C语言第25天,练习题,喝汽水 || 数组使奇数全部位于偶数的前面

结构体#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>struct S { int a; int b;};int main() { struct S a, * p = &a; a.a = 99; printf("%d\n", a.a);//99 printf("%d\n", p->a);//99 printf("%d\n", (*p).a);//99 //printf("%d\n", *p.a);//

2021-07-26 11:43:01 67

原创 C语言第24天,练习题,水仙花数 || 打印菱形

水仙花数#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>//水仙花数int main() { int i = 0; for (i = 0; i <= 100000; i++) { //判断i是否为水仙花数(自幂数) //1.计算i的位数 n位数 int n = 1; int tmp = i; int sum = 0; while (tmp /= 10)

2021-07-25 20:06:40 59

原创 C语言第24天,练习题,字符串逆序输出 || 求Sn=a+aa+aaa+aaaa+......的前n项之和

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>int main() { unsigned long pulArray[] = { 6,7,8,9,10 }; unsigned long* pulPtr; pulPtr = pulArray; //pulPtr - 元素6的地址 *(pulPtr + 3) += 3; //pulPtr+3 - 元素9的地址 printf("%d,%d\n", *pulPtr, *(pulPt

2021-07-25 18:52:06 77

原创 C语言第24天,指针难题

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>int main() { int a[5] = { 1,2,3,4,5 }; int* ptr = (int*)(&a + 1); printf("%d,%d\n", *(a + 1), *(ptr - 1));//2,5 //a是首元素地址,a+1是第二个元素的地址 //ptr-1是元素 5 的地址 return 0;}#define _CRT_SECURE_NO

2021-07-25 17:21:56 212

原创 C语言第23天,sizeof(),strlen()的运用示例(超详细)

整型数组,字符数组#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <string.h>int main() { //数组名是首元素的地址 //例外: //1.sizeof(数组名) - 数组名表示整个数组 //2.&数组名 - 数组名表示整个数组 //整型数组 - sizeof int a[] = { 1,2,3,4 };//4*4=16 printf("%d\n", sizeof

2021-07-24 17:33:58 136

原创 C语言第22天,指针(六)

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>int main() { int arr[10] = { 0 }; int(*p)[10] = &arr;//取出数组的指针 int(*pf)(int, int);//函数指针 int(*pfArr[4])(int, int);//pfArr是函数指针数组 int(*(*ppfArr)[4])(int, int) = &pfArr; //ppfArr是一个数组指

2021-07-22 16:45:54 46

原创 C语言第21天,指针(五),计算器(使用函数指针数组)

1.计算器 不使用函数指针数组#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>//计算器void menu() { printf("*********************\n"); printf("** 1.add 2.sub **\n"); printf("** 3.mul 4.div **\n"); printf("** 0.exit **\n");}int Add(int x

2021-07-21 19:13:15 89

原创 C语言第21天,指针(四),函数指针 | 函数指针数组

函数指针#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>//函数指针int Add(int x, int y) { int z = 0; z = x + y; return z;}void Print(char* str) { printf("%s\n", str);}int main() { int a = 10; int b = 20; int arr[10] = { 0 }; int(*p)[10]

2021-07-21 18:50:36 77

原创 C语言第21天,指针(三),传参

一维数组传参#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>//一维数组传参void test(int arr[]) { }//okvoid test(int arr[10]) { }//okvoid test(int* arr) { }//okvoid test2(int* arr[20]) { }//okvoid test2(int* arr) { }//okvoid test2(int** arr) {

2021-07-20 16:19:15 44

原创 C语言第20天,指针(二),数组指针

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>int main() { int* p1 = NULL;//p1是整型指针-指向整型的指针-可以存放整型的地址 char* pc = NULL;//pc是字符指针-指向字符的指针-可以存放字符的地址 //数组指针-指向数组的指针-存放数组的地址 //arr - 首元素地址 //&arr[0] - 首元素地址 //&arr - 数组的地址 int arr[10]

2021-07-19 19:21:35 52

原创 C语言第20天,指针(一)

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>int main() { char arr1[] = "abcde";//地址不同 char arr2[] = "abcde"; if (arr1 == arr2) { printf("yes/n"); } else { printf("no\n"); } printf("----------------------\n"); char* p1 = "abcde

2021-07-19 17:58:13 42

原创 C语言第19天,数据的存储(一)

原码,反码,补码#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>int main() { int a = 20;//4个字节-32bit //00000000000000000000000000010100 - 原码 //00000000000000000000000000010100 - 反码 //00000000000000000000000000010100 - 补码 //0x00000014 int b = -10;

2021-07-16 19:32:14 57

原创 C语言第19天,结构体

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>//描述一个学生//struct 机构体关键字 Stu-结构体标签 struct Stu-结构提类型typedef struct Stu { //成员变量 char name[20]; short age; char tele[12]; char sex[5];}Stu;void Print1(Stu tmp) { printf("name: %s\n", tmp.na

2021-07-16 15:38:17 53

原创 C语言第19天,递归练习题(五)

输入一个正整数,返回组成它的数字之和#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>//输入一个正整数,返回组成它的数字之和int DigitSum(unsigned int num) { if (num > 9) { return DigitSum(num / 10) + num % 10; } else { return num; }}int main() { unsigned int num =

2021-07-16 13:59:28 63

原创 C语言第18天,练习题(四)

用函数打印arr数组的内容,不使用数组下标,使用指针#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>//用函数打印arr数组的内容,不使用数组下标,使用指针void Print(int* p, int sz) { int i = 0; for (i = 0; i < sz; i++) { printf("%d ", *(p + i)); }}int main() { int arr[] = { 1,2,3,4

2021-07-15 17:56:25 75

原创 C语言第18天,二进制练习题(三)

写一个函数,求一个数的二进制(补码)表示中有几个1#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>int count_one(int n) { int count = 0; while (n) { if (n % 2 == 1) { count++; } n = n / 2; } return count;}int main() { int a = 0; scanf("%d", &a); /

2021-07-15 16:07:45 171

原创 C语言第17天,练习题(二)

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>int main() { int arr[] = { 1,2,3,4,5 }; short* p = (short*)arr;//short 两个字节 int i = 0; for (i = 0; i < 4; i++) { *(p + i) = 0;//四次初始化,,每次2个字节,4次8个字节--即前两个数字 } for (i = 0; i < 5; i++)

2021-07-14 16:17:03 136

原创 C语言第16天,数组练习题(一)

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include<string.h>int main() { char str[] = "hello world"; printf("%d %d\n", sizeof(str), strlen(str)); //12 11 ---sizeof包括\0 char axX[] = "abcdefg"; char axY[] = { 'a','b','c','d',

2021-07-13 20:22:41 68

原创 C语言第16天,初始指针

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>int main() { //指针类型决定了指针进行解引用的时候,能够访问空间的大小 //int*p; *p能够访问4个字节 //char*p; *p能够访问4个字节 //double*p; *p能够访问8个字节 int a = 0x11223344; int* pa = &a; char* pc = &a; double* pd = &a; pri

2021-07-13 18:21:27 76

原创 C语言第15天,操作符(二)

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>void test1(int arr[]) { printf("%d\n", sizeof(arr));}void test2(char ch[]) { printf("%d\n", sizeof(ch));}int main() { int arr[10] = { 0 }; char ch[10] = { 0 }; printf("%d\n", sizeof(arr));

2021-07-11 17:53:20 77

原创 C语言第15天,操作符(一)

#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>//交换两个变量的值,不使用第三个变量int main() { //加减法-可能会溢出 int a = 3; int b = 5; a = a + b; b = a - b; a = a - b; printf("a=%d b=%d\n", a, b); printf("--------------\n"); //异或法 int a2 = 4; int b2 =

2021-07-11 15:50:07 38

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除