Skip to content

Instantly share code, notes, and snippets.

View Phitherek's full-sized avatar
💭
-> GitLab

Phitherek_ Phitherek

💭
-> GitLab
View GitHub Profile
@Phitherek
Phitherek / mergesort.c
Created March 9, 2012 10:52
MergeSort w C wg algorytmu Hawka
#include <stdlib.h>
#include <stdio.h>
void merge(int* A, int p, int q, int r) {
printf("merge(A, %d, %d, %d)\n", p, q, r);
int a,b,i,j,k;
int* L;
int* P;
a = q-p+1;
printf("a=%d\n", a);
@Phitherek
Phitherek / decider.cpp
Created March 12, 2012 20:43
Phitherek_' s Decider v. 0.1
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
srand(time(NULL));
cout << "Phitherek_' s Decider v. 0.1 (c) 2012 by Phitherek_" << endl;
char pt;
do {
cout << "Poziom trudności testu (l - Łatwy, s - Średni, t - Trudny, q - zakończ): ";
@Phitherek
Phitherek / strings.c
Created March 22, 2012 11:50
Program do sprawdzenia, jak zachowują się stringi (z wykładu Hawka).
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
char a[3];
char b[3];
char c[3];
char tek[4];
*a = "aaa";
@Phitherek
Phitherek / COMPILATION
Created March 26, 2012 16:47
Phitherek_' s Decider v. 0.1 GTK
Kompiluj przy użyciu/compile using:
g++ -o decider_gtk decider_gtk.cpp `pkg-config --cflags --libs gtk+-2.0`
@Phitherek
Phitherek / radiozet
Created April 22, 2012 21:42
A script that plays a Polish radio station RadioZet with MPlayer and offers server choice
#!/bin/bash
if [[ $# -ne 1 ]]
then
echo "Usage: $0 [server_number 03-40]"
else
if [ $1 != "03" ] && [ $1 != "04" ] && [ $1 != "05" ] && [ $1 != "06" ] && [ $1 != "07" ] && [ $1 != "08" ] && [ $1 != "09" ] && [[ $1 -lt 10 ]] || [[ $1 -gt 40 ]]
then
echo "Usage: $0 [server_number 03-40]"
else
mplayer http://radiozetmp3-$1.eurozet.pl:8400/
@Phitherek
Phitherek / robot.c
Created June 21, 2012 22:05
Implementacja algorytmu z robotem w C
#include <stdio.h>
#include <stdlib.h>
// Mamy robota, który ma przejść daną odległość, możliwe są ruchy o 1, 2 lub 3. Chcemy się dowiedzieć, ile jest kombinacji, w jakich nasz robot może przejść tą odległość.
struct wyniki { // Struktura przechowuje liczbę możliwości dla następnego kroku o
int o; // 1
int t; // 2
int th; // 3
};
@Phitherek
Phitherek / minesweeper.cpp
Created July 23, 2012 23:12
Minesweeper v. 0.1
// Minesweeper v. 0.1 (c) 2012 by Phitherek_
#include <iostream> // Do streamów IO
#include <cstdlib> // EXIT_SUCCESS i inne przydatne rzeczy z C
#include <iomanip> // Do manipulacji streamem IO - ustawienie szerokości wierszy, aby zwiększyć czytelność planszy
using namespace std; // Odkrycie standardowej przestrzeni nazw - bo nic nam nie będzie kolidować z tą przestrzenią
struct field { // Struktura opisująca pole na planszy:
int bomb; // Czy jest bomba na tym polu? 1 - tak, 0 - nie
int checked; // Czy pole jest odkryte? 1 - tak, 0 - nie
int ba; // Ilość bomb wokół pola
@Phitherek
Phitherek / actselector.cpp
Created September 14, 2012 13:24
algoprep
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include "algoprep.h"
using namespace std;
struct activity {
int s;
int f;
};
@Phitherek
Phitherek / 3m.cpp
Created September 18, 2012 19:10
3m temporary code paste
#include <iostream>
#include <cstdlib>
#include <sys/socket.h> // For sockets
#include <sys/types.h> // For getaddrinfo
#include <arpa/inet.h> // For inet addr conversion
#include <netdb.h> // For getaddrinfo
#include <cstring> // For memset
#include <cerrno>
#include <unistd.h>
#include <string>
@Phitherek
Phitherek / NOTICE
Created October 4, 2012 19:53
algoprep p. 2
Use algoprep.cpp, algoprep.h and Makefile from here: https://gist.github.com/3721876