自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 第三次上机第一题

题目 1、类的定义与基本操作class Fraction {//数据成员,访问控制属性默认是私有int m_numerator = 0; // 分子默认为0; C++11int m_denominator = 1; //分母默认为1;public://公有成员函数Fraction(int above = 0, int below = 1) :m_numerator(above), m_denominator(below) {cout << “Constructor called”

2021-01-03 12:55:26 85

原创 求矩阵中上三角形、下三角形、对角线元素和

#include<iostream>using namespace std;int main() { int matrix[3][3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { cin >> matrix[i][j];//输入一个3*3的矩阵 } } int a = 0, b = 0, c = 0; int(*p)[3] = matrix; for (int i

2020-12-11 21:02:30 1678 1

原创 将矩阵中和值最大的一行元素与首行调换

#include<iostream>using namespace std;int main() { int a[3][4], b[3][4] = { 0 },sum = 0, max = 0, k = 0;cin >> a[0][0] >> a[0][1] >> a[0][2] >> a[0][3] >> a[1][0] >> a[1][1] >> a[1][2] >> a[1][3] &g

2020-12-10 19:22:05 569

原创 10.输出星型图案

#include<iostream>using namespace std;int main() { int n, i; cout << "输入正整数n"; cin >> n; for (i = 1; i <= n; i++) { cout << 2*i- 1 << endl; } for (i = n + 1; i <= 2 * n - 1; i++) { cout << 2 * (2*n-1-i)

2020-11-13 22:20:43 321

原创 9.每行五个素数

#include<iostream>#include<cmath>using namespace std;int main() { int m, i; int a=0; for (m = 100; m <= 200; m++) { for (i = 2; i <= sqrt(m); i++) { if (m % i == 0) { break; } else { cout << m << '\t';

2020-11-13 22:13:14 107

原创 8.判断素数

#include<iostream>#include<cmath>using namespace std;int main() { int m, i; cout << "输入一个数m="; cin >> m; for (i = 2; i <=m; i++) { if (m % i == 0) { cout << "不是素数" << endl; break; } else { cout &

2020-11-13 22:11:19 65

原创 7.圆的面积

#include<iostream>using namespace std;int main() { double radius, area; double pi = 3.14; for (radius = 1; radius <= 10; radius++) { area = pi * radius * radius; if (area > 100) break; cout << area << endl; } return 0;

2020-11-13 22:05:08 109

原创 6.统计正数和平均数

#include<iostream>using namespace std;int main() { int a[10], i, n = 0, sum = 0; double x; for (i = 1; i <= 10; i++) { cin >> a[i]; if (a[i] > 0) { n++; } sum += a[i]; } x = sum / 10; cout << "正数的个数为" << n &

2020-11-13 22:04:20 112

原创 5.输出矩阵

#include<iostream>using namespace std;int main() { int m, n; for (m = 1; m <= 4; m++) { for (n = 1; n <= 5; n++) { cout << m * n << '\t'; } cout << endl; } return 0;}

2020-11-13 22:01:07 250

原创 4.累加到N

#include<iostream>using namespace std;int main() { int n, s; cout << "输入一个数n="; cin >> n; if(n > 0) { s = ((1 + n) * n) / 2; cout << s; } return 0;}

2020-11-13 22:00:26 106

原创 3.水仙花数

#include<iostream>int main() { int a, b, c, n; for (n = 100; n <= 999; n++) { a = n / 100; b = (n / 10) % 10; c = n % 10; if (a * a * a + b * b * b + c * c * c == n) { std::cout << n << std::endl; } } return 0;}

2020-11-13 21:59:45 57

原创 2.海伦公式

#include<iostream>#include<cmath>using namespace std;int main() { double a, b, c, p, s; cout << "输入三角形的三个边长"; cin >> a >> b >> c; p = (a + b + c)/2; s=sqrt(p * (p - a) * (p - b) * (p - c)); cout << "三角形的面积

2020-11-13 21:59:13 150

原创 1,比大小

#includeusing namespace std;int main(void){int a, b, c, max, min;cout << “输入的三个数为:”;cin >> a >> b >> c;if (a > b) {max = a;min = b;}else max = b;min = a;if (max < c) {cout << c <<">"<< max &l

2020-11-13 21:56:52 82

空空如也

空空如也

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

TA关注的人

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