Skip to content

Instantly share code, notes, and snippets.

View odeblic's full-sized avatar

Olivier de BLIC odeblic

View GitHub Profile
@odeblic
odeblic / stl_size.cpp
Created July 30, 2017 13:14
To be tested...
#include <iostream>
#include <list>
#include <forward_list>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#define PRINT(X) std::cout << #X " -> " << sizeof(X) << std::endl;
@odeblic
odeblic / stats.cpp
Created July 30, 2017 07:56
To be tested...
#include <iostream>
#include <limits>
#include <math.h>
// x[i]=i++ + 1;
int array[5][2] = {{1, 2, 3}, {10, 20, 30}};
int x = array[++i, ++j];
@odeblic
odeblic / casts.c
Created July 30, 2017 07:54
To be tested...
int my_int;
float my_float;
char my_char;
long long my_longlong;
struct { char a; long long b; } my_aligned;
@odeblic
odeblic / streams.cpp
Created July 30, 2017 07:53
To be tested...
#include <iostream>
#include <string>
#include <sstream>
int main(int argc, char ** argv)
{
std::string content;
std::stringstream buffer;
if (argc > 1)
@odeblic
odeblic / regex.cpp
Created July 29, 2017 15:42
To be tested...
#include<string>
#include<set>
#include<iostream>
#include<sstream>
#include<regex>
using namespace std;
set<string> get_strings(istream& is, regex pat);
@odeblic
odeblic / signed_unsigned.c
Last active July 30, 2017 05:18
Signed and unsigned integers
#include <stdio.h>
int main(int argc, char* argv[])
{
union
{
signed short int signed_short_int;
unsigned short int unsigned_short_int;
struct {unsigned char char1; unsigned char char2;} s;
} u;
@odeblic
odeblic / alignment.c
Created July 29, 2017 14:47
To be tested...
#include <stdio.h>
typedef struct
{
int a;
char b;
int c;
char d;
} s1;
@odeblic
odeblic / hacktest.cpp
Created July 29, 2017 14:37
To be tested...
#include <iostream>
#include <math.h>
/*
* Complete the function below.
*/
int getIntegerComplement(int n) {
if(n <= 0)
{
@odeblic
odeblic / containers.cpp
Created July 29, 2017 14:35
To be tested...
#include <iostream>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <unordered_set>
#include <algorithm>
using namespace std;
@odeblic
odeblic / console.cpp
Last active July 29, 2017 14:34
To be tested...
#include <iostream>
#include <iomanip>
//using namespace std;
void display(double n)
{
std::cout << "Flottant : \"" << n << "\" (précision " << std::cout.precision() << ")" << std::endl;
}