自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(15)
  • 问答 (1)
  • 收藏
  • 关注

原创 简单版的扫雷游戏

在此扫雷源文件编写中,我采用了二维数组来做(根据需要可以在类的对象数组定义中改变N的值来改变游戏范围),同时此处定义N时,要将其定义为静态成员,不然下面的数组处将会报错(非静态成员引用必须与特定对象相对)。#include<iostream>#include<iomanip> //调用库函数setw()#include<ctime>#include<cstdlib> #include<vector>#i.

2021-01-10 22:17:15 169 2

原创 第三次上机题目,主要是类和函数的应用

1,、类的定义与基本操作说明执行下列语句后,分别执行的什么操作,会输出什么?Fraction a;Fraction b(a);Fraction c = Fraction(3, 2);Fraction d1(2, 3), d2(4, 5);Fraction e1 = divide1(d1, d2);Fraction e2 = divide2(d1, d2);在上述类的定义基础上,完善下列操作: 1) 显示定义析构函数; 2) 获取分数的分子;3) 获取分数的分母; 4) 实现分数的约分; 5

2020-12-23 23:36:07 146

原创 第二次上机题目,主要是灵活应用指针,数组,string类型,和vector类型

第一题:已知一个矩阵,存储在一个二维数组中。将矩阵中和值为最大的那一行元素与首行对换。#include<iostream>using namespace std;int main(){ int s = 0,c=0,b=0; int p ; int a2d[3][5] = {{1,2,3,4,5},{2,3,4,5,6},{3,4,5,6,7}}; for (int j = 0; j != 5;j++) { s = s + a2d[0][j]; } for (i.

2020-12-11 01:15:33 148

原创 指针与数组的知识小结

他们之间看似简单实则暗藏玄机!来看实践!#include<iostream>using namespace std;int main() { //指针知识小结: 指针提供了一种间接访问数据的方式 //1、指针的定义 int i = 100; int* p = &i; //定义一个指向int类型对象的指针对象p,把i的地址放到p中,也就是说p指向了i cout << *p << endl; //解引用操作符*,访问i的内容,输出为

2020-12-10 16:09:15 227

原创 关于string类型,字符数组,C风格字符串之间的区别和各自的用法小结

话不多说,上代码,实践和探索才是走向真理的捷径!#include<iostream>#include<string>using namespace std;int main() { //string类型整理 string a = "Pluto is a dwarf planet.\n" ; //复制初始化 cout << a.at(6) << endl; //访问单个字符(注意字符也包括空格) a.at(

2020-12-08 18:55:42 242

原创 2020-11-13

从键盘输入一个正整数 n,输出一个星型图案,其中第 n 行的*号个数为 2n-1 个。#include<iostream>using namespace std;int main() { int n,i,k,m,a,b; cout << "请输入n="; cin >> n; for (i = 1; i <= n;i++) { a = 2 * n -1-(2*i-1);

2020-11-13 12:47:51 391 1

原创 2020-11-13

求 100-200 之间的全部素数并按照每 5 个一行进行输出#include<iostream>#include<cmath>using namespace std;int main() { int n,k,i,s; s = 0; n = 100; for (n = 100; n <= 200;n++) { k = int(sqrt(n)); for (i = 2; i <= k;i++) { if (n % i == 0)break;

2020-11-13 12:46:11 52

原创 2020-11-13

从键盘输入一个数 m,判断这个数是否为素数。#include<iostream>#include<cmath>using namespace std;int main() { int m, n, k; cout << "请输入一个数m="; cin >> m; k = sqrt((double)m); for (n = 2; n <= k; n++) { if (m%n == 0) { cout << "m不是素数

2020-11-13 12:44:40 48

原创 2020-11-13

已知半径 radius,采用循环结构计算半径 1~10 区间内圆的面积area。且当 area>100 时结束程序运行。#include<iostream>using namespace std;int main() { double radius, area; radius = 1; do { area = 3.14 * radius * radius; cout << area << endl; ++radius; if (area

2020-11-13 12:42:43 45

原创 2020-11-13

从键盘随机输入 10 个数,统计其中正数的个数及其平均数#include<iostream>using namespace std;int main() { double sum, q, a, b, c, d, e, f, g, h, i, j,x; cout << "a,b,c,d,e,f,g,h,i,j="; cin >> a >> b >> c >> d >> e >> f >> g

2020-11-13 12:41:38 39

原创 2020-11-13

输出以下 4*5 的矩阵。1 2 3 4 52 4 6 8 103 6 9 12 154 8 12 16 20#include<iostream>using namespace std;int main() { int i, m; m = 1; for (i = 1; i <= 5; i++) { cout << i << '\t'; }cout << endl; for (i = 1; i <= 5; i++) {

2020-11-13 12:39:29 47

原创 2020-11-13

从键盘输入一个数 N,计算 1+2+3+……+N 的值;要求能一直输入一直计算,直到输入一个负数停止#include<iostream>using namespace std;int main() { int n,sum; cout << "n="; cin >> n; if (n > 0) { sum = (n * (n + 1)) / 2; } else if (n = 0) { sum = 0; } else { cout

2020-11-13 12:37:53 44

原创 求解1000以内的水仙花数

打印出所有的“水仙花数”,所谓“水仙花数”是指一个三位数,其各位数字的立方和等于该数本身。#include<iostream>using namespace std;int main() { int num, a, b, c; for (num = 100; num <= 999; num++) { a = num / 100; b = (num - a*100) / 10; c = num - a*100 - b*10; if (num == a * a *

2020-11-13 12:35:26 420

原创 2020-11-13

采用海伦公式,求三角形的面积,三角形的三个边从键盘输入#include<iostream>#include<cmath>using namespace std;int main() { int a, b, c,s,p; cout << "a,b,c="; cin >> a >> b >> c; p = (a + b + c) / 2; s = sqrt(p * (p - a) * (p - b) * (p - c));

2020-11-13 12:33:13 44

原创 输入三个实数,按从大到小的顺序输出。

输入三个实数,按从大到小的顺序输出。#include<iostream>using namespace std;int main(){ double x, y, z; cout << "x,y,z="; cin >> x >> y >> z; if (x > y && x > z) { cout << x; if (y > z)cout << y << z;

2020-11-13 12:31:29 3619

空空如也

空空如也

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

TA关注的人

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