Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
为什么用C++编译能通过G++就Compile Error呢?我在本机测试的时候也是用的g++啊#include <string> #include <iostream> #include <set> #include <memory.h> class DNAString { public: void calculate(); private: std::string seq; int measure; friend bool operator<(const DNAString& left, const DNAString& right); friend std::istream& operator>>(std::istream& is, DNAString&); friend std::ostream& operator<<(std::ostream& os,const DNAString&); }; std::istream& operator>>(std::istream& is, DNAString& s) { is>>s.seq; s.calculate(); return is; } std::ostream& operator<<(std::ostream& os, const DNAString& s) { os<<s.seq; return os; } bool operator<(const DNAString& left, const DNAString& right) { return left.measure < right.measure; } void DNAString::calculate() { measure=0; const int length = seq.length(); char* p=new char[length]; memcpy(p, seq.c_str(), length ); for(int i=length-2; i>=0; --i){ int k=i; for(int j=i+1; j<length;j++){ if(p[k] > p[j]){ std::swap(p[k], p[j]); measure++; k=j; } } } delete p; } int main() { int m,n; DNAString tmp; std::multiset<DNAString> s; typedef std::multiset<DNAString>::iterator Iter; std::cin>>m>>n; for(int i=0; i< n; ++i){ std::cin>>tmp; s.insert(tmp); } for(Iter iter=s.begin(); iter!= s.end(); ++iter){ std::cout<<(*iter) <<std::endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator