- 博客(10)
- 收藏
- 关注
原创 1218上机3
```cpp #include<iostream> using namespace std; #include<cmath> #define PI 3.14159 class Point { private: double m_x = 0, m_y = 0; public: void setx(double x) { m_x = x; } void sety(double y) { m_y = y; } double getx() const { retur.
2020-12-26 00:02:16 61
原创 1218上机2
#include<iostream> #include<vector> using namespace std; int msearch(int a[], int low, int high) { //折半查找法 int key = 17; int pose = 0; while (low <= high) { pose = (low + high) / 2; if (ke
2020-12-25 23:10:26 64
原创 1218上机
#include<iostream> using namespace std; class Fraction { private: int m_numerator = 0; int m_denominator = 1; public: int getdenominator() const { return m_denominator; } //获取分母 int getnumerator() const { return m_numerator
2020-12-25 23:08:22 54
原创 125上机4
#include<iostream> #include<ctime> #include<vector> using namespace std; int main() { srand(time(0)); vector<int>v1; int n; cout << "请输入有几个人:"; cin >> n; int m = 0; for (int i = 1; i <= n; i++)
2020-12-12 08:03:29 64
原创 125上机3
#include<iostream> #include<string> using namespace std; int main() { string str1; int is_palindrome = 1; cout << "请输入内容:" << endl; getline(cin, str1); //因为cin遇到空
2020-12-10 20:30:50 69
原创 125上机2
#include<iostream> using namespace std; int main() { int i, j; int sum1 = 0, sum2 = 0, sum3 = 0; int a1d[3][3] = { {1,2,3}, {4,5,6}, {7,8,9} }; int(*p2d)[3] = a1d; for (i = 1; i < 3; i++) { for (j = 0; j < i; j++) sum1 += *(p
2020-12-10 20:24:34 58
原创 125上机1
#include<iostream> using namespace std; int main() { int i = 0, j = 0, sum = 0; int row = 0; int maxsum = 0; int i1=0; int a2d[3][5] = { {2,3,4,5,6}, {7,8,9,9,8}, {7,6,5,4,3} }; for (i = 0; i < 3; i++) { sum = 0; for (j = 0;
2020-12-10 20:22:51 54
原创 auto与decltype笔记整理
auto与decltype 1.auto ①auto是通过初始值的数据类型来推导对象的类型。如:auto pi = 3.14159, rad = 1.0;这条语句中pi、rad都为double类型的值,故此处auto推导为double。**但是,如果初始值是一个const类型,auto会忽略const属性,故对const类型推导仍需加上const。**如:const auto rad = pi; ②如果希望auto定义一个类型的引用,需要显式指出引用类型。如:int i = 0, &ri = i;
2020-12-08 09:34:11 93
原创 数组与指针课堂笔记整理
一、如果或&紧跟类型说明,则定义对象为指针或引用;如果或&出现在表达式中,则为解引用或取址符,e.g. int i = 0; int *ptr = &i; //*紧随int,故ptr为指针;&在表达式中,故为取址符 int &ref = *ptr; //&紧随int,故ref为引用;*在表达式中,故为解引用 二、const int 和 const * int ①const int * ptr;为常量指针 常量指针指向常量,可以改变对象但不可以改
2020-12-01 08:14:10 80
原创 双十一上机
1. #include<iostream> using namespace std; int main() { int a, b, c, max; cin >> a >> b >> c; max = a; if (b > max) { max = b; if (a > c) { cout << max << '\t' << a << '\t' << c;
2020-11-14 07:16:29 111
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人