自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 谭浩强c++第三版10-7

#include<iostream>using namespace std;//定义 教师类和学生类,一部分数据成员相同 class Student{public: Student(int n, string na, char s, int sc) :num(n), name(na), sex(s), score(sc) {} int getnum() { re...

2020-04-12 17:00:15 148

原创 谭浩强c++第三版10-6

#include<iostream>using namespace std;//处理复数与double类型数的相加 ,结果存放在double型变量d1中,再以复数形式输出class Complex{public: Complex() { real = 0; imag = 0; } //默认构造函数 Complex(double r, double i); /...

2020-04-12 15:58:21 112

原创 谭浩强c++第三版10-5

#include<iostream>using namespace std;//重载+ 使之用于矩阵相加//重载<<,>>,实现矩阵输入输出class Martrix{public: //Martrix(); friend Martrix operator+(Martrix&, Martrix&); friend istre...

2020-04-12 15:17:30 246

原创 谭浩强c++第三版10-4

#include<iostream>using namespace std;//重载+ 使之用于矩阵相加class Martrix{public: Martrix() {} void input(); friend Martrix operator+(Martrix&, Martrix&); void display();private: in...

2020-04-12 14:54:26 167

原创 谭浩强c++第三版10-3

#include<iostream>using namespace std;//重载+ 任意顺序都能使用 class Complex{public: Complex(int r = 0, int i = 0) :real(r), imag(i){} void display(); Complex operator+(Complex& c); Complex...

2020-04-12 14:34:24 381

原创 谭浩强c++第三版10-2

#include<iostream>using namespace std;//重载+-*/实现复数的运算 重载作为类成员函数class Complex{public: Complex(double r=0,double i=0):real(r),imag(i){} void display(); Complex operator+(Complex&); ...

2020-04-12 14:16:03 126

原创 谭浩强c++第三版10-1

#include<iostream>using namespace std;//重载+号(非成员,非友元),复数相加class Complex{public: Complex(int r=0,int i=0):real(r),imag(i){} int getreal(); int getimag(); void display();private: int ...

2020-04-10 23:17:33 141

原创 谭浩强c++第三版9-12

#include<iostream>using namespace std;//类模板外定义各成员函数template<class numtype>class Compare{public: Compare(numtype a, numtype b) { x = a; y = b; } numtype max(); numtype min(...

2020-04-02 14:46:09 97

原创 谭浩强c++第三版9-11

#include<iostream>using namespace std;//将例9-13程序中Time声明为Date的友元类class Date;class Time{public: Time(int h,int m,int s):hour(h),minute(m),sec(s){} void display(Date&);private: int ...

2020-04-02 14:32:10 152

原创 谭浩强c++第三版9-10

#include<iostream>using namespace std;//将例9-13程序中display不放在time类中而作为普通函数class Date;class Time{public: Time(int h,int m,int s):hour(h),minute(m),sec(s){} friend void display(Date&, ...

2020-04-02 14:27:21 166

原创 谭浩强c++第三版9-9

#include<iostream>#include<iomanip>using namespace std;//商店销售某一商品,每天公布统一的折扣class Goods{public: Goods(int nu,int q,double p):num(nu),quantity(q),price(p){} void total(); static d...

2020-04-02 11:23:32 105

原创 谭浩强c++第三版9-5

#include<iostream>using namespace std;//建立对象数组,内放5个学生数据class Student{public: Student(int n,double s):num(n),score(s){} friend void max(Student *);private: int num; double score;};...

2020-04-02 10:14:17 243

原创 谭浩强c++第三版9-4

#include<iostream>using namespace std;//建立对象数组,内放5个学生数据class Student{public: Student(int n,double s):num(n),score(s){} void display();private: int num; double score;};void Student...

2020-04-01 22:19:34 213

原创 谭浩强c++第三版8-6

#include<iostream>using namespace std;//输入三个长方体的体积,编写一个程序求。。。class cube{public: void set_value(); void calcu_volume(); void display();private: int length; int width; int height; i...

2020-03-31 21:28:56 147

原创 谭浩强c++第三版8-5

//arraymax.hclass Array_max{public: void set_value(); void max_value(); void display_value();private: int array[10]; int max;};//arraymax.cpp#include<iostream>#include"arraymax.h"...

2020-03-31 21:09:23 99

原创 谭浩强c++第三版7-4

#include<iostream>using namespace std;//写一个函数print,打印一个学生的成绩数组,编写input函数,用以输入数据struct Student{ string name; int num; double score[3];};void print(Student& stu){ cout << s...

2020-03-30 21:37:37 123

原创 谭浩强c++第三版7-3

#include<iostream>using namespace std;//写一个函数print,打印一个学生的成绩数组struct Student{ string name; int num; double score[3];};void print(Student& stu){ cout << stu.num <<" ...

2020-03-30 21:29:16 113

原创 谭浩强c++第三版7-2

#include<iostream>using namespace std;//定义结构体变量,输入年月日能计算并输出该日在本年是第几天,编写一个函数daysstruct Days{ int year; int month; int day;};int days(int y, int m, int d){ int days[12] = { 31,28,31,...

2020-03-30 21:05:45 139

原创 谭浩强c++第三版7-1

#include<iostream>using namespace std;//定义结构体变量,输入年月日能计算并输出该日在本年是第几天struct Days{ int year; int month; int day;};int main(){ Days Date; int days[12] = { 31,28,31,30,31,30,31,31,30,...

2020-03-30 20:48:24 96

原创 谭浩强c++第三版6-20

#include<iostream>using namespace std;//指向指针的指针对n个整数排序输出void sort(int** p, int n){ int* temp; for(int i=0;i<n;i++) for(int j=0;j<n-1-i;j++) if (**(p + j) > ** (p + j + 1))...

2020-03-30 15:07:18 78

原创 谭浩强c++第三版6-19

#include<iostream>using namespace std;//指向指针的指针对五个字符串排序输出void str_sort(char** p){ char* temp; //冒泡法排序 for (int i = 0; i < 5; i++) for (int j = 0; j < 4 - i; j++) if (strcmp(*...

2020-03-30 14:47:48 98

原创 谭浩强c++第三版6-18

#include<iostream>using namespace std;//写一程序,输入月份,输出该月英文名,使用指针数组int main(){ const char* month[] = { "January","February","March","April","May","June","July","August","September","October"...

2020-03-30 14:37:48 96

原创 谭浩强c++第三版6-17

#include<iostream>using namespace std;//自己写一个strcmp函数int strcmp(char* p1, char* p2){ int i = 0; while (*(p1 + i) == *(p2 + i)) //循环条件为所有字符相同 if (*(p1 + i++) == '\0') ...

2020-03-29 18:06:35 87

原创 谭浩c++第三版6-16

#include<iostream>using namespace std;//输入字符串,将字符串内连续整数依次存放于一数组中,统计共有多少个整数int main(){ char str[100]; int a[100] = { 0 },k=0,key=0,sum=0; cout << "请输入字符串:"; gets_s(str); char* p ...

2020-03-29 17:30:17 126

原创 谭浩强c++第三版6-14

#include<iostream>using namespace std;//将n个数按输入时的顺序的逆序排列void sort_a(int* p, int n){ for (int i = 0; i < n / 2; i++) { int* p1 = p+i; //p1指向前1,2,3,4...个元素 int* p2 = p + n -...

2020-03-29 16:51:57 82

原创 谭浩强c++第三版6-13

#include<iostream>#include<cmath>using namespace std;//用矩形法求定积分的通用函数//矩形法 定积分的几何定义double func_sin(double x){ return sin(x);}double func_cos(double x){ return cos(x);}dou...

2020-03-29 16:39:31 95

原创 谭浩强c++第三版6-12

#include <iostream>#include<cstring>using namespace std;void str_sort(char* p[]){ for (int i = 0; i < 5; i++) for (int j = 0; j < 4 - i; j++) if (strcmp(*(p+j),*(p+j+1))&g...

2020-03-26 16:34:23 146

原创 谭浩强c++第三版6-11

#include<iostream>using namespace std;//用一函数对十个等长字符串进行排序void str_sort(string* p){ //直接使用冒泡法进行排序 for(int i=0;i<5;i++) for(int j=0;j<4-i;j++) if (p[i] > p[i+1]) { stri...

2020-03-26 15:54:30 130

原创 谭浩强c++第三版6-10

#include<iostream>using namespace std;//将5*5矩阵中最大元素放在中心,四个角放最小元素void martrix_func(int* p){ int *max = p; int *min = p; for(int i=0;i<5;i++) for (int j = 0; j < 5; j++) { if...

2020-03-26 14:31:01 110

原创 谭浩强c++第三版6-9

#include<iostream>using namespace std;//写一函数将一个3*3数组转置void martrix(int* p){ for (int i = 0; i < 3; i++) for (int j = i; j < 3; j++) { int temp = *(p + 3 * i + j); *(p...

2020-03-24 17:33:59 89

原创 谭浩强c++第三版6-8

#include<iostream>using namespace std;//输入一行文字,找出大写,小写,空格,数字和其他字符的个数int main(){ char str[100]; int upper = 0, lower = 0, dight = 0, space = 0, other = 0; cout << "请输入一串字符:"; gets...

2020-03-24 15:37:08 129

原创 谭浩强c++第三版6-7

#include<iostream>using namespace std;//n个字符的字符串,用一个函数将m个字符开始的全部字符复制成另一个void string_copy(char* p1, char* p2, int m){ for (int i = 0; i < m - 1; i++) //p1指向字符串1的第m位 p1++; f...

2020-03-24 15:21:33 108

原创 谭浩强c++第三版6-6

#include<iostream>using namespace std;//写一个函数,求一字符串的长int length(char* p){ int count = 0; while (*p != '\0') { count++; p++; } return count;}int main(){ char str[20]; cout &l...

2020-03-19 21:57:41 83

原创 谭浩强c++第三版6-5

#include<iostream>using namespace std;//n个人围成一圈顺序排号。排第三位的人退出,问留下的原来是几号?int main(){ int n; int index; //每个人编号 int step = 0; //报数顺序 int count = 0; //退出人数 int ...

2020-03-19 21:42:59 132

原创 谭浩强c++第三版6-4

#include<iostream>using namespace std;//有n个整数,使前面各数往后移m个位置,最后m个数变成前面m个数void move(int* a, int n, int m){ int array_end = *(a + n - 1); //array_end是数列末位数 for (int* p = a + n - ...

2020-03-18 22:38:45 82

原创 谭浩强c++第三版6-3

#include<iostream>using namespace std;//输入十个整数,将其中最小的数与最大的数对换,最大的数与最后一个数对换//写三个函数 1.输入十个数 2.处理 3.输出void input(int *p){ cout << "输入十个整数:"; for (int i = 0; i < 10; i++) cin &gt...

2020-03-18 20:02:53 133

原创 谭浩强c++第三版6-2

#include<iostream>using namespace std;//输入三个整数,按从小到大顺序输出int main(){ string str1, str2, str3; cout << "请输入三个字符串:"; cin >> str1 >> str2 >> str3; string* p1 = &amp...

2020-03-18 19:32:31 96

原创 谭浩强c++第三版6-1

#include<iostream>using namespace std;//输入三个整数,按从小到大顺序输出int main(){ int a, b, c; cout << "请输入三个整数:"; cin >> a >> b >> c; int* p1 = &a, * p2 = &b, * p3 =...

2020-03-18 19:22:19 89

原创 谭浩强c++第三版5-17

#include<iostream>using namespace std;//输入十个学生姓名,学号和成绩,将不及格者输出int main(){ string name[10]; int num[10], score[10]; for (int i = 0; i < 10; i++) { cout << "输入学生" << i +...

2020-03-13 20:44:54 94

原创 谭浩强c++第三版5-16

#include<iostream>using namespace std;//输入一个字符串,将其中字符逆序输出int main(){ string str; cout << "请输入字符串:"; cin >> str; int n = str.size(); //n为字符串的长度 for (int i = 0; i < n ...

2020-03-13 20:11:03 113

空空如也

空空如也

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

TA关注的人

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