自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 C++ const 修饰指针。

1.const 修饰指针。====> 常量指针,特点:指针的指向可以改,但是指针指向的值不能改。int a = 10;int b = 10;const int * p = &a;//两种情况:*p = 20;(错)p = &b;(对)2.const 修饰常量。 ====> 指针常量,特点:指针的指向不可以改,但是指针指向的值可以改。int a = 10;int b = 10;int * const p = &a;//两种情况:*p = 2

2021-07-27 20:53:23 126

原创 C++ 函数的分文件编写。

函数分文件编写一般有4步。1.创建后缀名为.h的头文件。2.创建后缀名为.cpp的源文件。3.在头文件中写函数的声明。4.在源文件中写函数的定义。swap.h 文件:#include<iostream>using namespace std;// 函数声明int swap(int a,int b);swap.cpp 文件:#include "swap.h"// 函数定义int swap(int a, int b){ int temp = a; a

2021-07-27 20:21:51 179

原创 C++ 实现冒泡排序

#include <iostream>using namespace std;/* 利用冒泡的原理,假设按照从小到大的排,那么前一个元素必然比后一个元素小,反之就交换两者的位置,有n个元素,每次会选出一个最大的,则要进行n-1次选择,在每次选择中,两两之间元素的比较次数为n-已进行的选择次数-1.*/void bubbleOrder(){ int arr[] = { 1,2,3,4,5,6,7,8,9,8,9,5,7,5,8,7,6,2,4,7,8,2,3,89,5,8,565..

2021-07-26 19:54:56 84

原创 2021-07-24 打印乘法表。

#include <iostream>using namespace std;void MultiplicationFormulaTable()// 打印1-9乘法表{ for (int i = 1; i < 10; i++) { for (int j = 1; j <= i; j++) { cout << i << "*" << j << "=" << j * i << " ";.

2021-07-24 21:32:22 98

原创 2021-07-24 敲桌子游戏。

#include <iostream>using namespace std;void knockTable() { // 敲桌子:从1数到100,如果数字个位中含有7,或者十位含有7, // 或者是7的倍数,打印敲桌子,否者打印数字。 for (int i = 1;i<101;i++) { if ( (i%10==7) || ((i/10)%10==7) || (i%7==0)) { cout << i <<"敲一下桌子!".

2021-07-24 21:13:04 214 1

原创 2021-07-24 使用C++求出三位数以内的水仙花数。

#include <iostream>using namespace std;void calculate() { // 计算出三位数中的所有水仙花数:1^3 + 5^3 + 3^3 = 153 int num = 100; while (num < 1000) { //百位数 int baiNum = (int)(num / 100); //十位数 int shiNum = (int)((num - baiNum * 100) / 10); //个.

2021-07-24 20:47:40 238

原创 C++ 学习 打卡第一天

猜数字游戏使用C++完成猜测1~100间的某个数字。#include <iostream>#include <ctime>using namespace std;void guessNumber(){ //设置随机数种子 srand((unsigned int)time (NULL)); // 生成1-100间的随机数 int randNumber = rand() % 100 + 1; int guessNumber = 0; cout &lt

2021-07-24 20:17:27 143 1

空空如也

空空如也

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

TA关注的人

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