Skip to content

Instantly share code, notes, and snippets.

View YaoC's full-sized avatar
🏠
Working from home

C.YAO YaoC

🏠
Working from home
View GitHub Profile
#include <iostream>
using namespace std;
struct ListNode{
char info;
ListNode* next;
ListNode(char newinfo, ListNode* newNext) {
info = newinfo;
next = newNext;
}
#define MAXLEN 128
class String {
public:
int size()const;
String(const char* s = "");
String operator + (const String s);
char & operator [] (int index);
char operator [] (int index)const;
private:
char buf[MAXLEN];
@YaoC
YaoC / stack.h
Created October 4, 2016 13:36
实现一个简单的字符栈
#define STACK_CAPACITY 1000
class Stack {
private:
char* array;
int pos;
public:
Stack(); // constructor for a stack
void push( char c ); // adds c to the top of the stack
char pop(); // removes top element, returns it
char top(); // returns the top element, w/o removing
@YaoC
YaoC / test_stack.cpp
Created October 4, 2016 13:35
利用stack.h反转字符串
#include <iostream>
#include "stack.h"
using namespace std;
int main() {
Stack strStack;
cout<<"Input s string: ";
string str;
getline(cin,str);