Skip to content

Instantly share code, notes, and snippets.

@PiotrWegrzyn
PiotrWegrzyn / AutodeskTasks.cpp
Last active June 20, 2018 17:23
Task 1 Each node in a binary tree contains an integer value and two pointers to next-level nodes: “left” and “right”. Write a function that takes a pointer to a root of a tree and checks whether the tree is sorted. Task 2 There is a 3D point and a line segment (bounded 3D line) given by endpoints. (..)write a function that will compute the dista…
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <iomanip>
using namespace std;
struct Tree{
int val;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@PiotrWegrzyn
PiotrWegrzyn / pthreadLinuxThreads.cpp
Last active June 6, 2018 11:48
This program generates a table filled with random numbers in a thread, then counts the sum and avarage of each row in a separate thread and then counts the avarage of sums of all rows in a thread.
//compile with: g++ name.cpp -o name -lpthread
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <assert.h>
using namespace std;
@PiotrWegrzyn
PiotrWegrzyn / JacobianAndGaussSeidel.cpp
Last active June 4, 2018 21:37
Numeryczne rozwiązywanie układu równań liniowych metodą Jacobiego.
#include <iostream>
#include <cstdlib>
#include <time.h>
using namespace std;
//matrix of constatns:
//|a0, a1, a2, a3|
//|a4, a5, a6, a7|
//|a8, a9,a10,a11|
//matrix of variables: |x0,x1,x2...xn|
@PiotrWegrzyn
PiotrWegrzyn / Jacobian.cpp
Last active June 5, 2018 12:48
Numeryczne rozwiązywanie układu równań liniowych metodą Jacobiego.
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
void metoda_Jacobiego();
bool gauss(int, double**, double*);
@PiotrWegrzyn
PiotrWegrzyn / PointInPolygonGrahamJarvisAndNaiveMethods.cs
Last active June 6, 2018 11:48
Computational geometry - Point inside a polygon problem and finding the Convex Hull with Graham, Jarvis and Naive methods (c#)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@PiotrWegrzyn
PiotrWegrzyn / monteCarloAndTrapezoidIntegration.cpp
Created May 5, 2018 13:29
Calculating errors of both montecarlo and trapezoid integration based on precalculated real value.
#include <iostream>
#include <cstdlib>
#include <time.h>
double f(double x) {
return x*x;
}
@PiotrWegrzyn
PiotrWegrzyn / NewtonCotesQuadrature.cpp
Created May 1, 2018 02:00
Metody numeryczne 01.05.18
#include <iostream>
using namespace std;
double compositeTrapezoidRule(double * pointsX, double *pointsY, int N){
double h = (pointsX[N - 1] - pointsX[0]) / (N - 1);
double area = 0.0;
area += pointsY[0] + pointsY[N - 1];
for (int i = 1; i < N - 1; i ++){
area += 2 * pointsY[i];
@PiotrWegrzyn
PiotrWegrzyn / GrafikaKomputerowaKrzyweB-Skladane.cs
Last active April 23, 2018 10:19
C#;Grafika komputerowa;Krzywe B-Składane;April2018
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
#include <iostream>
using namespace std;
double newton(int ** &resultsTable, int * tabX, int* tabY, int k , int i) {
if (resultsTable[i][k] == NULL) {