This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include "stack.h" | |
using namespace std; | |
int main() { | |
Stack strStack; | |
cout<<"Input s string: "; | |
string str; | |
getline(cin,str); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
struct ListNode{ | |
char info; | |
ListNode* next; | |
ListNode(char newinfo, ListNode* newNext) { | |
info = newinfo; | |
next = newNext; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by chengyao on 2017/1/12. | |
*/ | |
public class Main { | |
public static void main(String[] args) { | |
Rectangle rect = new Rectangle(1, 3, 2.5, 4); | |
System.out.println("长方形的位置:("+rect.getX()+","+rect.getY()+"),面积为:"+rect.getArea()); | |
rect = new Rectangle(3, 5, 4, 8); | |
System.out.println("现在长方形的位置:("+rect.getX()+","+rect.getY()+"),面积为:"+rect.getArea()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
#include <fstream> | |
#include <sstream> | |
#include <vector> | |
#include "ics46goody.hpp" | |
#include "array_queue.hpp" | |
#include "array_priority_queue.hpp" | |
#include "array_set.hpp" | |
#include "array_map.hpp" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class KEY,class T> | |
const T& ArrayMap<KEY,T>::operator [] (const KEY& key) const { | |
int i = index_of(key); | |
if (i != -1) | |
return map[i].second; | |
std::ostringstream answer; | |
answer << "ArrayMap::operator []: key(" << key << ") not in Map"; | |
throw KeyError(answer.str()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template<class KEY,class T> | |
T& ArrayMap<KEY,T>::operator [] (const KEY& key) { | |
int i = index_of(key); | |
if (i != -1) | |
return map[i].second; | |
this->ensure_length(used+1); | |
map[used++] = Entry(key,T()); | |
++mod_count; | |
return map[used-1].second; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main(int argc, char *argv[]) { | |
cout<<"你输入了"<<argc-1<<"个参数"<<endl; | |
if(argc==1) | |
return 0; | |
if(argc==2) | |
cout << "读入图片" << argv[1] << endl; | |
if(argc==3) { | |
cout << "指定尺寸错误!\n"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
OlderNewer