- 博客(43)
- 问答 (3)
- 收藏
- 关注
原创 c++程序设计语言第三章练习
6.6.1int i = 0;while(i < max_length){ if(*input_line == '?') quset_count++;}6.6.2 (a = (((b + (c * d)) << 2) & 8)) (a & (077 != 3)) ((a == b) || ((a == c) && (c < 5))) (c = (x != 0)) ((0 <=
2021-07-04 17:59:59
219
1
原创 c++程序设计语言第二章练习
5.9.1#include <iostream>#include <string>using namespace std;int main(void){ char x = 'a'; char * ch = &x; int num[10]; for(int i = 0; i < 10; i++) { num[i] = i; } int (&n)[10] = num; stri
2021-07-01 18:10:42
199
原创 c++程序设计语言第一章练习
by:学完cpp primer plus之后对游戏辅助感兴趣去学了7章windows程序设计之后研究了下imgui,把imgui自带的绘图函数封装了个绘图类,平时写辅助够用了又回来继续cpp了4.11.1#include <iostream>int main(void){ std::cout << "Hello World!" << std::endl; return 0;}我理解的意思是声明改定义,定义改声明,写了没把全部写完4.11.2
2021-06-30 21:52:19
182
1
原创 C++ Primer Plus第十八章练习
18.12.1#include <iostream>#include <initializer_list>using namespace std;template <typename T>T average_list(initializer_list<T>);int main(void){ auto q = average_list({15.4, 10.7, 9.0}); cout << q << endl
2021-06-17 15:21:09
163
原创 C++ Primer Plus第十七章练习
看完16章之后觉得又行了 直接去看了2天windows程序设计 看晕了又回来继续cpp了17.8.1#include <iostream>using namespace std;int main(void){ int count = 0; cout << "请输入一串字符串:"; char temp[30]; cin.get(temp, 30, '$'); for(int i = 0; temp[i]; i++) co
2021-06-15 16:34:44
189
原创 C++ Primer Plus第十六章练习
不得不说16章的STL初学者噩梦 看到算法那直接省略跳过了16.10.1#include <iostream>#include <string>using namespace std;bool Petest(const string &);int main(void){ cout << "otto是否是回文: " << (Petest("otto") ? "是" : "不是") << endl; return
2021-06-10 00:03:41
218
原创 C++ Primer Plus第十五章练习
15.8.1很简单 只需要多添加2个方法和一个状态就行 不过令我不解的是为什么需要将remote前向声明tv.h#ifndef TV_H#define TV_H#include <iostream>using namespace std;class Remote;//????这是为何 书上说如果声明为友元类就不需要前向声明了 如果没有这个不通过编译class Tv{public: friend class Remote; enum { Off, On };
2021-06-03 21:28:03
153
原创 C++ Primer Plus第十四章练习
14.7.1Wine.h#ifndef WINE_H#define WINE_H#include <iostream>#include <valarray>#include <string>using namespace std;template <typename T1, typename T2>class Pair{private: T1 a; T2 b;public: Pair(void) {} i
2021-05-29 23:37:20
224
原创 C++ Primer Plus第十三章练习
13.11.1成员数据并无不需要动态内存分配所以不需要拷贝构造与赋值构造Cd.h#ifndef CD_H#define CD_H#include <iostream>#include <cstring>using namespace std;class Cd{private: char performers[50]; char label[20]; int selections; double playtime;public:
2021-05-24 16:31:13
190
原创 C++ Primer Plus第十二章练习
12.10.1Cow.cpp#include "Cow.h"Cow::Cow(void){ strcpy(name, "xswl"); hobby = new char[1]; hobby[0] = '\0'; weight = 0;}Cow::Cow(const char * nm, const char * ho, double wt) : weight(wt){ strcpy(name, nm); hobby = new char[strl
2021-05-21 14:51:24
168
原创 C++ Primer Plus第十一章练习
11.9.1类和类定义直接使用????上的 main添加个fstream头文件让他输出进文件里就行了vector.h#ifndef VECTOR_H_#define VECTOR_H_#include <iostream>#include <cstdlib>#include <ctime>#include <cmath>#include <fstream>using namespace std;namespace VECTOR
2021-05-18 14:40:39
175
原创 C++ Primer Plus第十章练习
10.10.1main.cpp#include "bank.h"int main(void){ bank a, b("伞兵", "111111", 999999); a.show(); b.show(); b.fetch(5631); b.show(); b.save(5631); b.show(); return 0;}bank.h#ifndef BANK_H#define BANK_H#include <iostr
2021-05-15 16:40:32
151
原创 C++ Primer Plus第九章练习
9.6.1main.cpp#include "golf.h"int main(void){ golf arr[2]; char temp1[30]; int temp2, i; for(i = 0; i < 2; i++) { cout << "请输入球手名字: "; cin.getline(temp1, 29); if(!temp1[0]) break;
2021-05-12 20:38:35
115
原创 C++ Primer Plus第八章练习
8.8.1#include <iostream>using namespace std;void show(const char *, int n = 0);int main(void){ show("xswl"); show("xswl", 1); return 0;}void show(const char * s1, int n){ if(n) cout << s1 << endl;}8.8.2
2021-05-10 15:26:12
154
原创 C++ Primer Plus第七章练习
7.13.1#include <iostream>using namespace std;int Calculate(int, int);int main(void){ int num1, num2; while(cin >> num1 >> num2 && num1 > 0 && num2 > 0) cout << num1 << "与" << nu
2021-05-07 16:01:39
180
原创 C++ Primer Plus第六章练习
6.11.1#include <iostream>#include <cctype>using namespace std;int main(void){ char ch; while(cin >> ch && ch != '@') { if(isupper(ch)) ch = tolower(ch); else if(islower(ch))
2021-05-05 15:45:07
116
原创 C++ Primer Plus第五章练习
5.9.1#include <iostream>using namespace std;int main(void){ int sum = 0; int one, two; cout << "请指定第一个数: "; cin >> one; cout << "请指定第二个数: "; cin >> two; for(int i = one; i <= two; i++)
2021-05-04 15:18:13
139
原创 C++ Primer Plus第四章练习
4.13.1#include <iostream>using namespace std;int main(void){ cout << "What is your first name? "; char fname[20]; cin.getline(fname, 19); cout << "What is your last name? "; char lname[20]; cin.getline(lname, 1
2021-05-02 19:16:26
120
原创 C++ Primer Plus第三章练习
3.7.1#include <iostream>using namespace std;int main(void){ const float Feet = 0.0833; cout << "请输入您的身高:______\b\b\b\b\b\b"; int inch; cin >> inch; cout << "转换为英尺后:" << Feet * inch << endl; re
2021-04-29 17:54:48
110
原创 C++ Primer Plus第二章练习
2.7.1#include <iostream>using namespace std;int main(void){ cout << "姓名:XXX" << endl; cout << "地址:XXX" << endl; return 0;}2.7.2#include <iostream>using namespace std;int main(void){ cout <&l
2021-04-28 21:57:02
168
原创 Essential c++第五章笔记
①模板类创建实体必须在模板类名称之后接一个尖括号,放置类型②复习下友元机制:友元按类型分为3种1.普通非类成员函数作为友元定义在内外都行,声明必须在类内,该友元并不属于类成员函数,但可以访问私有成员2.类的成员函数作为友元声明时必须已经定义了包含友元函数的类,而且需要::运算符,通常的做法是先定义包含友元函数的类,再定义原始类,同样可以访问私有成员3.类作为友元类作为友元注意,友元类和原始类之间的相互依赖关系,友元类成员函数都可以是另一个类的友元函数,也可以访问私有成员by:这一章真给新手看
2021-04-25 15:07:58
134
原创 Essential c++第五章笔记
①派生类对象定义出后会先执行父类构造,然后执行子类构造,摧毁时则相反②简单的多态理解:同一个对象有不同的属性③静态成员函数无法被声明为虚函数④当一个成员函数被声明为虚函数后,派生类同名函数都自动成为虚函数.所以在子类声明该虚函数时,可以加也可以不加virtual关键字,加上只是更清晰,在类本身之外对虚函数定义时,不需要指明关键字virtual⑤每当派生类有某个成员与基类成员同名时,便会遮蔽住基类那份成员,在接下来的调用该成员就不是调用的基类成员,如果还想使用基类那份成员就必须使用::运算符⑥成员数
2021-04-24 20:44:09
129
原创 Essential c++第四章笔记
①在class中定义成员函数会被自动视为inline函数<练习>4.1main.cpp#include "Stack.h"int main(void){ Stack cc; cc.push("changshi"); cc.size(); cc.pop(); cc.peek(); return 0;}Stack.h#ifndef STACK_H#define STACK_H#include <vector>#in
2021-04-23 22:45:41
117
原创 Essential c++第三章笔记
①list容器的元素以一组指针相互链接:前向指针寻址下一个元素,回向元素用来寻址上一个元素②每个标准容器都会有提供begin()的操作函数并返回一个开始位置的迭代器,另一个end()函数也会返回最后一个元素的下一个元素的迭代器③const vector的迭代器需要const_iterator类型来接收,例:vector::const_iterator iter = cs.begin()④如果需要在最前端or最后端进行安插删除可使用deque容器效率更高⑤pop_back与pop_front俩个函数并
2021-04-22 17:39:10
115
原创 Essential c++第二章笔记
①函数如果有返回值,就必须在所有可能返回的点上将值返回<练习>2.1#include <iostream>using namespace std;bool fibon_elem(int, int &);int main(void){ int pos; cout << "Please enter a position:(-1 to quit)"; cin >> pos; while(pos > 0) { int elem
2021-04-21 16:30:11
154
原创 Essential c++第一章笔记
①照相机最基本的情况下可用7个浮点数表示,6个可分为2组x, y, z坐标,就不得不面对7个浮点数进行编程。class机制提供了程序内抽象化层次定义的能力,我们可以定义Point3d class来表示2组xyz,我们可再定义Camera class包含2个Point3d对象和一个浮点数,现在我们就是对Camera class的操作(class定义需包含iostream头文件)②string class定义在中③只有内建的数据类型才可以用同样的方式操作(<<, =, +等)④命名空间是将程序
2021-04-20 15:42:20
147
原创 C和指针第十八章编程练习
18.8.1使用codeblocks的汇编调试发现代码如下 push %ebp mov %esp,%ebp mov 0x8(%ebp),%edx mov 0xc(%ebp),%eax add %eax,%edx mov 0x10(%ebp),%eax add %edx,%eax pop %ebp ret然后发现codeblocks并不能写汇编vc++????✍内联汇编应该是_asm{
2021-03-31 12:09:21
216
原创 C和指针第十七章编程练习
17.10.1void resize_stack(size_t size){ assert(stack != NULL); stack_size = size; realloc(stack, sizeof(STACK_TYPE) * size); assert(stack != NULL);}17.10.2接口#include <stdio.h>#include <stdlib.h>#include <assert.h>
2021-03-30 18:07:39
212
1
原创 C和指针第十六章编程练习
16.13.1#include <stdio.h>#include <stdlib.h>int main(int argc, char * argv[]){ if(argc < 2) { perror("argc"); exit(1); } int i; long num = strtol(argv[1], NULL, 10); for(i = 2; i < 37 &&
2021-03-27 16:49:46
723
原创 C和指针第十五章编程练习
15.22.1#include <stdio.h>int main(void){ int ch; while((ch = getchar()) != EOF) putchar(ch); return 0;}15.22.2#include <stdio.h>int main(void){ char temp[81]; while(fgets(temp, 80, stdin)) fputs(temp
2021-03-24 16:21:13
324
原创 C和指针第十四章编程练习
14.10.1void print_ledger(int a){ #if OPTION_LONG print_ledger_long(); #elif OPTION_DETAILED print_ledger_detailed(); #else print_ledger_default(); #endif}14.10.2cpu_type.h#ifndef CPU_TYPE_H_INCLUDED#define CPU_TYPE_H_
2021-03-20 20:34:39
136
原创 C和指针第十三章编程练习
13.10.1#include <stdio.h>#include <ctype.h>int control(char ch);int space(char ch);int num(char ch);int low(char ch);int up(char ch);int pun(char ch);int noprint(char ch);int main(void){ int (*pt[7])(char) = {control, space, num, lo
2021-03-20 13:21:10
277
原创 C和指针第十二章编程练习
12.8.1必须知道链表类型 修改改函数可用于遍历链表typedef struct list{ int i; struct list * n;}List;int listcount(List * d){ int count = 0; while(d->n) { count++; d = d->n; } return count;}12.8.2无序有序都可以用这个List * find
2021-03-18 22:55:32
347
原创 C和指针第十一章编程练习
11.11.1void * my_calloc(size_t n, size_t m){ void * temp = malloc(n * m); if(!temp) return NULL; return temp;}11.11.2int * read(void){ int count = 1; int * temp = (int *)malloc(sizeof(int)), value; puts("请输入一列整数:");
2021-03-17 12:21:30
187
原创 C和指针第十章编程练习
10.11.1typedef struct{ int area; int swboard; int standnum;}phone;typedef struct{ int year; int month; int day;}data;typedef struct{ data dat; float time; phone your; phone his; phone pay;}longcall;10.11.2typedef struct{ char name[
2021-03-16 16:03:02
268
原创 C和指针第九章编程练习
9.14.1#include <stdio.h>#include <ctype.h>int main(void){ char str[50]; if(gets(str) && str[0]) { int i; int char_num[7] = {0}; for(i = 0; str[i]; i++) { if(iscntrl(str[i])) char_num[0]++; else if(isspace(str[i]
2021-03-15 22:47:08
539
原创 C和指针第八章编程练习
8.8.1#include <stdio.h>int main(void){ static char char_value[3][6][4][5] = { { { {}, {}, {}, {} }, { {}, {}, {}, {} }, { {}, {}, {}, {} }, { {}, {}, {}, {}
2021-03-14 15:52:00
439
原创 C和指针第七章编程练习
7.11.1int hermite(int n, int x){ if(n <= 0) return 1; else if(n == 1) return 2 * x; else return 2 * x * hermite(n - 1, x) - 2 * (n - 1) * hermite(n - 2, x);}7.11.2循环写法int gcd(int m, int n){ if(m < 0 ||
2021-03-13 12:13:30
217
原创 C和指针第六章编程练习
6.18.1char * find_char(const char * source, const char * chars){ if(source == NULL || chars == NULL || *source == '\0' || *chars == '\0')//检测 return NULL; const char * temp = chars;//用个临时指针保存chars的起始地址 while(*source) { whi
2021-03-12 14:39:10
409
原创 C和指针第五章编程练习
5.9.1#include <stdio.h>#include <ctype.h>int main(void){ char ch; while((ch = getchar()) != '\n') { if('A' <= ch && ch <= 'Z') ch = tolower(ch); putchar(ch); } return 0;}5.9.2
2021-03-10 17:02:21
238
空空如也
nasm使用extern关键字无法解析外部符号
2021-08-15
vs2019的项目属性中没有qt project settings选项
2021-07-18
使用fputs写入文件时报错?
2021-05-01
TA创建的收藏夹 TA关注的收藏夹
TA关注的人