cs11_c++_lab1】的更多相关文章

lab1.cpp #include "Point.hh" #include <iostream> #include <cmath> using namespace std; double computeArea(Point &a, Point &b, Point &c) { double x=a.distanceTo(b); double y=b.distanceTo(c); double z=c.distanceTo(a); ; dou…
exercise1.cc #include <iostream> #include <vector> #include <stdlib.h> #include <algorithm> using namespace std; int myFunction() { + ; } int main() { vector<); generate(vi1.begin(), vi1.end(), myFunction);//可用generate函数初始化,与下功能…
wcount.cc #include <iostream> #include <map> #include <string> #include <algorithm> #include <ctype.h> // So we don't have to type "std::" everywhere... using namespace std; string processWord(string &word); voi…
expressions.hh #ifndef EXPRESSIONS_HH #define EXPRESSIONS_HH #include "environment.hh" #include <string> #include <stdexcept> #include <cassert> #include <cmath> using namespace std; class Expression { public: Expression(…
heap.hh #ifndef HEAP_HH #define HEAP_HH #include <iostream> #include <stdexcept> #include <cassert> using namespace std; template <typename T, int maxsize>class heap//模板类heap,类型T,常量maxsize { private: int num_values;//当前存储的元素的数量 T v…
SparseVector.hh class SparseVector { private: //结构体不一定会用到,不用初始化 struct node { int index; int value; node *next; node() : index(index), value(value), next(next) {} }; //这些才是真正的数据成员,要初始化的 int size; node *start; void clear(); void copyList(const SparseV…
SparseVector.hh class SparseVector { private: //结构体不一定会用到,不用初始化 struct node { int index; int value; node *next; node() : index(index), value(value), next(next) {} }; //这些才是真正的数据成员,要初始化的 int size; node *start; void clear(); void copyList(const SparseV…
Matrix.hh class Matrix { int row; int col; int *p; void copy(const Matrix &m); void clearup(); public: Matrix(); Matrix(int x,int y); ~Matrix(); Matrix(const Matrix &m); const int getrows() const; const int getcols() const; void setelem(int x,int…
Matrix.hh class Matrix { int row; int col; int *p; public: Matrix(); Matrix(int x,int y); ~Matrix(); Matrix(Matrix &m); int getrows(); int getcols(); void setelem(int x,int y,int elem); int getelem(int x,int y); void add(Matrix &m); void subtract(…
1. 背景 goto语句虽然目前已经不提倡使用,但是用起来还是很方便,尤其是老代码中见的比较多. 在改动有goto语句的老代码时需要特别注意,是否跳过来资源的释放.有用变量的初始化等等. 很久之前写c程序时,有些提交系统要求变量必须在函数开始地方全部申明,最近遇到了"crosses initialization of XXX"知道为什么了.就是因为有可能跳过变量的声明. 2. 代码例子 例子1: #include <iostream> class Test{ public:…