This file contains 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
string decode(string cipherText, int shift) | |
{ | |
size_t len = cipherText.size(); | |
string res(cipherText); | |
for(size_t i = 0; i < len; i++){ | |
int c = res[i] - 'A'; | |
if(c - shift < 0) | |
c = 26 + (c - shift); | |
else | |
c = c - shift; |
This file contains 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
vector<string> split(const string &str, char delim){ | |
vector<string> res; | |
size_t current = 0, found; | |
while((found = str.find_first_of(delim, current)) != string::npos){ | |
res.push_back(string(str, current, found - current)); | |
current = found + 1; | |
} | |
res.push_back(string(str, current, str.size() - current)); | |
return res; | |
} |
This file contains 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
vector<string> split(const string &str, const string &delim){ | |
vector<string> res; | |
size_t current = 0, found, delimlen = delim.size(); | |
while((found = str.find(delim, current)) != string::npos){ | |
res.push_back(string(str, current, found - current)); | |
current = found + delimlen; | |
} | |
res.push_back(string(str, current, str.size() - current)); | |
return res; | |
} |
This file contains 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
vector<string> split(const string &str, char delim){ | |
istringstream iss(str); string tmp; vector<string> res; | |
while(getline(iss, tmp, delim)) res.push_back(tmp); | |
return res; | |
} |
This file contains 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
vector<string> split(const string &str){ | |
istringstream iss(str); vector<string> res; | |
copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(res)); | |
return res; | |
} |
This file contains 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
boost_split, vector<string> v; | |
boost::algorithm::split(v, str, bind2nd(equal_to<char>(), ' ') |
This file contains 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 <cstdlib> | |
#include <cstring> | |
#include <cstdio> | |
#include <wchar.h> | |
#include <string> | |
#include <iconv.h> | |
This file contains 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 "stdafx.h" | |
#include "Windows.h" | |
#include "winnls.h" | |
#include <string> | |
#include <cstdio> | |
using namespace std; | |
This file contains 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 <sys/file.h> | |
#include <pthread.h> | |
#include <assert.h> | |
#include <semaphore.h> | |
#include <errno.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <fcntl.h> | |
static int locked = 0; |
This file contains 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
class Chessboard | |
{ | |
public: | |
string changeNotation(string cell) | |
{ | |
ostringstream oss; | |
if(cell[0] >= 'a' && cell[0] <= 'h'){ | |
int c = static_cast<int>(cell[0]) - 'a' + 1; | |
int n = static_cast<int>(cell[1]) - '1'; |
OlderNewer