自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 求解最近邻基向量

#include <iostream>#include<cmath>#include <iomanip>using namespace std;double compare(double arr[],int len,int *num);//定义一个函数用于返回两个值,min和numint main(){ int d, n; double dis; while (cin >> d >> n)//多组输入,维度d和基向量个数n {.

2022-05-14 18:07:45 140

原创 统计某一字母出现的次数和位置

#include <iostream>#include<string>#include<vector>using namespace std;vector<int>loc;//定义一个整型的vector容器void position(char target, string str);//定义一个函数用于处理出现目标字符的个数和位置int main(){ char target; string str; while (cin >&gt.

2022-05-14 18:06:50 238

原创 矩阵转置,一维数组与二维数组的相互转换

#include <iostream>using namespace std;int main(){ int m, n; while (cin >> m >> n)//多组输入,确定二维数组的行数和列数 { int a = m * n; int* p = new int[a];//申请动态内存 for (int i = 0; i < a; i++) { .

2022-05-14 17:49:53 432

原创 交换数组的最大值和最小值

#include <iostream>using namespace std;int* change(int arr[], int n);//定义一个指针函数,用于对数组內部进行操作int main(){ int n; while (cin >> n)//多组输入,首先输入第一个数 { int arr[20];//定义一个数组用于储存输入的数 int i = 0; arr[i] = n; i++; while(cin>>arr[i...

2022-05-14 17:48:10 3514

原创 判断图书的ISBN号码是否正确

#include <iostream>#include<cstring>using namespace std;void cheak(char arr[])//定义一个函数用于检查ISBN号码{ char b[13] = { 0 };//定义一个数组用于存放ISBN号码中的数字 int sum = 0;//累加求和器 int last = 0;//最后一位数字在数组中的位置 int j = 0; for (unsigned int i ...

2022-04-24 10:28:00 1323

原创 实现一个函数void getMaxMin(int arr[], int len, int * max, int * min)用于计算一个数组的最大值和最小值

#include <iostream>using namespace std;void getMaxMin(int arr[], int len, int* max, int* min);//定义一个函数用于确定数组中的最大值和最小值int main(){ int arr[100];//定义数组并确定大小 int N; while (cin >> N)//多组输入并确定输入整数的个数 { for (int i = 0; i &l...

2022-04-23 17:46:49 1435

原创 使用字符数组编写一个程序,能够实现存储从键盘输入的两个字符串

#include <iostream>using namespace std;int get_length(char a[])//定义一个函数用于计算数组里元素的个数{ char* p = a;//定义一个字符指针指向数组a的首位元素 int count = 0;//计数器 while (*p++ != '\0') { count++; } return count;}int main(){ char a[30]...

2022-04-23 17:29:38 2851

原创 数组与斐波拉契数列

#include <iostream>using namespace std;int fab(int x);//定义一个函数使其能够返回对应斐波拉契数int main(){ int a[30];//定义一个数组并确定它的大小 for (int i = 1; i <= 30; i++) { a[i - 1] = fab(i);//将斐波拉契数填入数组 } int n; while (cin >> n)//多组...

2022-04-23 16:43:36 324

原创 设计一个Employee类,包含:雇员的编号、姓名、性别、出生日期等。其中“出生日期”声明为一个日期类的对象。用成员函数实现对人员信息的录入和显示。

#include <iostream>using namespace std;class CDate {//创建一个名为CDate的类,用于设置日期public: void setDate(int year, int month, int day) { Year = year; Month = month; Day = day; } void showDate(); //以下三个成员函数用于Employee中调...

2022-04-11 21:28:42 2554

原创 设计一个日期类(CDate),属性为年、月、日,成员函数为设置当前日期setDate(…)、当前日期加一天increaseDate()和显示日期showDate()

#include <iostream>using namespace std;class CDate {//定义一个名为CDate的类public: void setDate(int year, int month, int day) {//内联函数,向私密数据传递参数 Year = year; Month = month; Day = day; } void increaseDate(int a, int...

2022-04-11 21:13:30 2134

原创 设计一个学生类,成员变量包括学号、姓名、性别。成员函数如下:构造函数对学生的所有属性初始化,无参数的构造函数设置学号为1001,姓名为Zhangsan,性别为M(M代表男,F代表女)。性别需要使用枚举

#include<iostream>using namespace std;enum sex_set { F, M };//定义枚举类型enum sex_set sex;//定义枚举变量class StudentInfo{private: string xuehao; string xm, xb; sex_set sex;public: StudentInfo() :xuehao("1001"), xm("Zhangsan"), sex{M} {}...

2022-04-09 13:11:08 3075

原创 定义一个复数类Complex,使得下面的代码能够工作:Complex c1(3, 5); //用复数3+5i初始化c1Complex c2 = 4.5; //用实参4.

#include <iostream>using namespace std;class Complex {//命名一个Complex的类public: Complex(double shi, double xu) : realpart(shi), imaginarypart(xu) {};//构造函数,初始化参数 Complex(double shi) :realpart(shi), imaginarypart(0) {};//构造函数 void add(Comp...

2022-04-09 11:23:51 1399 1

空空如也

空空如也

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

TA关注的人

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