Skip to content

Instantly share code, notes, and snippets.

View HappyCerberus's full-sized avatar
📘
Moar books...

RNDr. Simon Toth HappyCerberus

📘
Moar books...
View GitHub Profile
@HappyCerberus
HappyCerberus / koza.c
Created March 14, 2012 13:25
Vzorove reseni problemu koza,vlk,zeli
/* Copyright (c) 2012 Mgr. Simon Toth ([email protected])
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
#include <stdio.h>
#define STATE_BAD 1
#define STATE_FINAL 2
/** \brief Kodovaci funkce pro zakodovani expandovaneho stavu do unikatniho cisla
@HappyCerberus
HappyCerberus / stdin_or_file.c
Created March 20, 2012 10:38
Simple code snipet that will either use stdin, or the open the file received as the first runtime parameter.
/* Copyright (c) 2012 Mgr. Simon Toth ([email protected])
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *input = stdin;
@HappyCerberus
HappyCerberus / pole.c
Created March 28, 2012 12:02
Prevod jednorozmerne - dvourozmerne pole
/* Copyright (c) 2012 Mgr. Simon Toth ([email protected])
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
*/
#include <stdio.h>
#include <string.h>
union multipole
{
int pole1[35];
@HappyCerberus
HappyCerberus / bludiste.c
Created April 8, 2012 13:50
Vzorove reseni bludiste (jendotlive faze = jednotlive verze souboru)
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int search(char **bludiste, int y, int x)
{
/* cil */
if (bludiste[y][x] == 'C') return 1;
/* policko neni volne, ani start */
@HappyCerberus
HappyCerberus / frekvence.cpp
Created September 23, 2012 00:08
Vzorové řešení programu "frekvence cisel"
#include <unordered_map>
#include <algorithm>
#include <iterator>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
unordered_map<int,int> freq;
istream_iterator<int> input(cin);
@HappyCerberus
HappyCerberus / array.c
Created September 25, 2012 08:53
Array (for stackoverflow)
#include <stdio.h>
int main()
{
int x[][3] = { { 1, 2, 3}, {1, 2, 3}};
int (*xptr)[3] = x;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 3; j++)
printf("%d ",xptr[i][j]);
@HappyCerberus
HappyCerberus / main.cpp
Created October 14, 2012 01:56
C++11 vs. volatile
#include <iostream>
#include <chrono>
#include <thread>
#include <atomic>
using namespace std;
// int notify;
// volatile int notify;
atomic<int> notify;
@HappyCerberus
HappyCerberus / iiter.cpp
Created October 15, 2012 13:36
Istream iterator demo
#include <iostream>
#include <iterator>
using namespace std;
int main()
{
istream_iterator<int> in(cin);
istream_iterator<int> eof;
long suma = 0;
@HappyCerberus
HappyCerberus / oiter.cpp
Created October 15, 2012 13:37
Ostream iterator demo
#include <algorithm>
#include <iostream>
#include <iterator>
using namespace std;
int main()
{
int pole[] = { 10, 20, 30 };
ostream_iterator<int> out(cout,", ");
@HappyCerberus
HappyCerberus / ioiter.cpp
Created October 15, 2012 13:37
Istream and ostream iterator demo
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
istream_iterator<double> in(cin);
istream_iterator<double> eof;