摘要: Person.hpp #ifndef PERSON_HPP #define PERSON_HPP #include<iostream> #include<string> #include<iomanip> using namespace std; class Person { public: Per 阅读全文
posted @ 2021-12-11 10:49 天问非攻 阅读(15) 评论(3) 推荐(0) 编辑
摘要: #include <iostream> #include <typeinfo> // definitation of Graph class Graph { public: void draw() { std::cout << "Graph::draw() : just as an interfac 阅读全文
posted @ 2021-11-26 16:58 天问非攻 阅读(34) 评论(3) 推荐(0) 编辑
摘要: vector_int.hpp #ifndef VECTOR_INT_HPP #define VECTOR_INT_HPP #include<iostream> #include<cassert> using namespace std; class Vector_int{ public: Vecto 阅读全文
posted @ 2021-11-06 16:30 天问非攻 阅读(30) 评论(3) 推荐(0) 编辑
摘要: task 1-4 1.普通数组、array、vector的相关性,以及,区别 vactor、array都可以定义一个数组,并与普通数组一样,都支持随机访问。 vector是动态数组类模板,数组对象大小是可变的,空间是在堆上按需分配,可以在尾部增加或删除数据项,用于数据项个数无法确定的场合。 arra 阅读全文
posted @ 2021-10-27 19:50 天问非攻 阅读(52) 评论(3) 推荐(0) 编辑
摘要: Complex.hpp文件源码 #ifndef COMPLEX_HPP #define COMPLEX_HPP #include<bits/stdc++.h> using namespace std; class Complex{ public: Complex(); Complex(double 阅读全文
posted @ 2021-10-24 12:01 天问非攻 阅读(30) 评论(3) 推荐(0) 编辑
摘要: 实验任务3 正确输出了按分数由高→低排序的信息 生成了文本文件file3.dat 数据信息是正确的且直观可读 实验任务4 正确输出了按分数由高到底排序的学生信息 生成了二进制文件file4.dat 数据不是直观可读的 #include<stdio.h> #include<stdlib.h> #def 阅读全文
posted @ 2020-12-30 22:52 天问非攻 阅读(32) 评论(0) 推荐(0) 编辑
摘要: // P280例8.15 // 对教材上的程序作了微调整,把输出学生信息单独编写成一个函数模块 // 打印不及格学生信息和所有学生信息程分别调用 #include<stdio.h> #include<stdlib.h> #include<string.h> #define N 3 // 运行程序输入 阅读全文
posted @ 2020-12-21 23:41 天问非攻 阅读(51) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> const int N=3; int main() { int a[N] = {1, 2, 3}; int i; printf("通过数组名及下标直接访问数组元素:\n"); for(i=0; i<N; i++) printf("%d: %d\n", &a[i] 阅读全文
posted @ 2020-12-16 17:53 天问非攻 阅读(66) 评论(0) 推荐(0) 编辑
摘要: 不能设计成函数返回值的方式 因为一元二次方程可能有两个根,而返回值只能有一个。 // 利用局部static变量计算阶乘 #include <stdio.h> long long fac(int n); // 函数声明 int main() { int i,n; printf("Enter n: ") 阅读全文
posted @ 2020-11-29 14:02 天问非攻 阅读(23) 评论(0) 推荐(0) 编辑
摘要: #include<math.h> #include<stdio.h> int main(){ float a,b,c,x1,x2; float delta,real,imag; printf("Enter a,b,c:"); while(scanf("%f%f%f",&a,&b,&c) != EOF 阅读全文
posted @ 2020-11-15 12:50 天问非攻 阅读(60) 评论(0) 推荐(0) 编辑