摘要:
#include using namespace std;#define LIST_INIT_SIZE 100#define LISTINCREMENT 10#define OVERFLOW -2#define TRUE 1#define FALSE 0#define OK 1#define ERROR 0#define INFEASIBLE -1typedef int ElemType;typedef int status;//线性表结构typedef struct{ ElemType *elem; int length; int listsize;}SqList;//初始... 阅读全文
摘要:
对于内置类型以外的初始化责任落在构造函数身上。如下:class PhoneNumber{};class ABEntry{public: ABEntry( const string& name, const string& address, const list& phones );private: string theName; string theAddress; list thePhones; int numTimesConsulted;};ABEntry::ABEntry( const string& name, const string& add 阅读全文
摘要:
一些成员函数改变对象,一些成员函数不改变对象。例如:int Point::GetY(){ return yVal;} 这个函数被调用时,不改变Point对象,而下面的函数改变Point对象:void Point:: SetPt (int x, int y){ xVal=x; yVal=y;} 为了使成员函数的意义更加清楚,我们可在不改变对象的成员函数的函数原型中加上const说明: class Point { public: int GetX() const; int GetY() const; void SetPt (int, int); void OffsetPt (int, i... 阅读全文
摘要:
char greeting[] = "hello";char* p = greeting; //non-const pointer,non-const dataconst char* p = greeting; //non-const pointer, const datachar* const p = greeting; //const pointer,non-const dataconst char* const p = greeting; //const pointer, const ... 阅读全文
摘要:
#include #include using namespace std;int main(){ int strwide; cin >> strwide; pair rotor[3][1000]; pair rotor_instead[3][1000]; string input; int t = 0; while( t > input; if ( input.size() == strwide ) { char start_1 = 'a'; char start_els... 阅读全文
摘要:
#include #include #include using namespace std;int main(){ string array[30][2]; string a,b; int t=0; while( cin >> a ) { if ( a == "0" ) { break; } else { cin >> b; } array[t][0] = a; array[t][1] = b; t++; } for ( int i = 0; i < t; i++ ) { const char *p = array[i][0].c_str() 阅读全文
摘要:
#include using namespace std;int main(){ int **array = new int *[100]; for ( int i = 0; i > x >> y ) { array[t][0] = x; array[t][1] = y; t++; } for ( int i = 0; i 100 && array[i][1] > 100 && t1 == 0 && t2 == 0 ) { win = array[i][0]; if ( win 100 && array[i 阅读全文
摘要:
1 #include 2 #include 3 #include 4 #define MAX_VERTEX_NUM 20 5 #define OK 1 6 #define ERROR 0 7 #define MAX 1000 8 using namespace std; 9 typedef struct Arcell 10 { 11 double adj; 12 }Arcell,AdjMatrix[MAX_VERTEX_NUM][MAX_VERTEX_NUM]; 13 typedef struct 14 { 15 char vexs[MAX_VERTEX_N... 阅读全文
摘要:
1 #include 2 using namespace std; 3 struct TreeNode //树结构体定义 4 { 5 char data; 6 TreeNode *lchild,*rchild; 7 }; 8 char getonech(char ar[]) 9 { static int i; 10 return ar[i++]; 11 } 12 void CreateBiTree(TreeNode *&p,char ar[]) //建立一个新树 13 { 14 char ch; 15 ... 阅读全文
摘要:
#include #include using namespace std;int main(){ int testcase_num; cin >> testcase_num; vector *result = new vector[testcase_num]; for ( int i = 0; i > number_transfered; vector transfered; int count = 0; int input; while( count > input ) { transfered.push_back(input); count++; } vector 阅读全文