Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment 0. #10

Merged
merged 1 commit into from
Sep 22, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions 13307130355/assignment0/src/Add.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#include <bits/stdc++.h>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不建议在我们课堂上这么用
That header file is not part of the C++ standard, is therefore non-portable, and should be avoided.
CF,Topcoder这种切题的形式,可能加这么一个东西用起来很方便。
出于一下两点考虑我不建议这么用。

  1. 对于我们这个课程,同学们需要知道每个用到的东西是从具体哪个包里面调用的
  2. java 有一个实践是不要用通配符来import的类.比如import java.util.*; 是不好的,你用的哪个类就去导入那个。

又因为我们的代码要互相review。希望同学们能够拉下来就能够编译和运行。 强烈建议不要这样写

using namespace std;

namespace Solve {

template<class T> inline vector<T>& operator<< (vector<T> &storage, const T& data) {
storage.push_back(data);
return storage;
}

template<class T> inline void operator!(const vector<T>& vect) {
for(const T& data : vect) {
cout << data << " ";
}
}

template<class T> inline queue<T>& operator<< (queue<T> &storage, const T& data) {
storage.push(data);
return storage;
}

template<class T> inline stack<T>& operator<< (stack<T> &storage, const T& data) {
storage.push(data);
return storage;
}

template<class T> inline queue<T>& operator>> (queue<T> &storage, T& data) {
data = storage.front();
storage.pop();
return storage;
}

template<class T> inline stack<T>& operator>> (stack<T> &storage, T& data) {
data = storage.top();
storage.pop();
return storage;
}

void main(void) {
ios::sync_with_stdio(false);
register int i, j;
long long a, b;
cin >> a >> b;
cout << a + b << endl;
}
}

int main(void) {
Solve::main();
}