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
#ifndef BUBBLE_SORT_H_ | |
#define BUBBLE_SORT_H_ | |
template <typename T> | |
void swap(T &a, T &b) | |
{ | |
T tmp = a; | |
a = b; | |
b = tmp; | |
} |
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
#ifndef FAST_IN_H_ | |
#define FAST_IN_H_ | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#define INPUT_BLOCK_SIZE 4096 * 512 | |
class FastInput |
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
int main(int argc, char *argv[]) | |
{ | |
int sockfd = socket(AF_INET, SOCK_STREAM, 0); | |
if (sockfd < 0) { | |
perror("new socket error"); | |
exit(-1); | |
} | |
struct sockaddr_in servaddr; | |
bzero(&servaddr, sizeof(servaddr)); |
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
string truncateUTF8(const string& src, size_t tolen) | |
{ | |
string dst; | |
dst.reserve(tolen); | |
size_t i = 0; | |
while (dst.size() < tolen && i < src.size()) | |
{ | |
size_t step = 0; | |
if ((src[i] & 0x80) == 0x00) // 1字节 | |
step = 1; |
OlderNewer