Блог пользователя HitmanBBa

Автор HitmanBBa, история, 11 лет назад, По-английски

Hi everyone.

I think we can spread the science over Codeforces community, by sharing our knowledge and experiences in our blog and in that way we learn and let others learn also :D.

I will start with something simple and I hope it will help you Codeforces members :D.

Did you know that [C++] got StringTokenizer like [Java], it's implemented as a function in STL <cstring> called strtok(char * str, char * delimiters) for more information.

  • Проголосовать: нравится
  • +38
  • Проголосовать: не нравится

»
11 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

Thanks HitmanBBa for this idea, I think it's worth trying :).

»
11 лет назад, скрыть # |
Rev. 4  
Проголосовать: нравится +8 Проголосовать: не нравится

C++ container compare operator overloads.

#include <iostream>
#include <vector>
#include <deque>
using namespace std;
int main(){
    vector<int> v1={2,3,5,9},v2={2,3,5,9},v3={2,3,5,8};
    deque<int> d1={2,3,5,9},d2={2,3,5,9},d3={2,3,5,8};
    if (v1==v2)
        cout << "v1 is equal to v2\n";
    else
        cout << "v1 is not equal to v2\n";
    if (d1==d2)
        cout << "d1 is equal to d2\n";
    else
        cout << "d1 is not equal to d2\n";
    if (v3<v1)
        cout << "v3 is less than v1\n";
    else
        cout << "v3 is not less than v1\n";
    if (d3<d1)
        cout << "d3 is less than d1\n";
    else
        cout << "d3 is not less than d1\n";
}

>,>=,<=,!= are similar. UPD: Also works with list.