Renaming labs

This commit is contained in:
Denis Nuțiu 2016-04-25 20:35:41 +03:00
parent bd4dc369ff
commit 515b097317
69 changed files with 83 additions and 0 deletions

View file

View file

View file

View file

View file

View file

View file

View file

View file

View file

BIN
lab08/1 Executable file

Binary file not shown.

View file

BIN
lab08/2 Executable file

Binary file not shown.

View file

BIN
lab08/cipher.o Normal file

Binary file not shown.

View file

53
lab09/2.c Normal file
View file

@ -0,0 +1,53 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define SIN 0.8660254
typedef struct{
double x, y;
} coordinate;
// Draws the computation
void draw_koch_snowflake(coordinate a, coordinate b, int t, FILE *f){
if(!t){
fprintf(f, "M%f %f L%f %F ", a.x, a.y, b.x, b.y);
return;
}
coordinate tmp = { (b.x - a.x)/3, (b.y - a.y)/3};
coordinate c = {a.x + tmp.x, a.y + tmp.y};
coordinate d = {a.x + (1.5 * tmp.x - SIN * tmp.y), a.y + (1.5 * tmp.y + SIN * tmp.x)};
coordinate e = {a.x + 2 * tmp.x, a.y + 2 * tmp.y};
draw_koch_snowflake(a, c, t-1, f);
draw_koch_snowflake(c, d, t-1, f);
draw_koch_snowflake(d, e, t-1, f);
draw_koch_snowflake(e, b, t-1, f);
}
// Provides a frame for the path
void framework(coordinate a, coordinate b, int t, FILE *f){
fprintf(f, "<path d=\" ");
draw_koch_snowflake(a, b, t, f);
fprintf(f, " \" fill=\"none\" stroke=\"black\" stroke-width=\"1\" />");
}
int main(int argc, char *argv[]){
int w, h, r;
w = h = 512;
r = w / 3;
int n = atoi(argv[1]);
FILE *f;
if( !(f=fopen("koch.svg","w")) ) return -1;
fprintf(f,"<svg xmlns=\"http://www.w3.org/2000/svg\" "
"xmlns:xlink=\"http://www.w3.org/1999/xlink\" "
"width=\"%d\" height=\"%d\">", w, h);
coordinate a = {w / 2, h / 2 + r};
coordinate b = {w / 2 - r * SIN, h / 2 - r * 0.5};
coordinate c = {w / 2 + r * SIN, h / 2 - r * 0.5};
framework(b, a, n, f);
framework(c, b, n, f);
framework(a, c, n, f);
fprintf(f, "</svg>");
fclose(f);
return 0;
}

BIN
lab09/a.out Executable file

Binary file not shown.

1
lab09/koch.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 138 KiB

15
lab09/t.c Normal file
View file

@ -0,0 +1,15 @@
#include <stdio.h>
#define N 3
void movedisks(int ndisks, char fromPeg, char toPeg, char auxPeg) {
if (ndisks == 1)
printf("Move disk 1 from [%c] to [%c]\n", fromPeg, toPeg);
else {
movedisks ( ndisks - 1 , fromPeg , auxPeg , toPeg ) ;
printf("Move disk %d from [%c] to [%c]\n", ndisks, fromPeg, toPeg);
movedisks ( ndisks - 1 , auxPeg , toPeg , fromPeg ) ;
}
}
int main(void) {
movedisks(N, 'A', 'C', 'B');
}

14
lab09/test.svg Normal file
View file

@ -0,0 +1,14 @@
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect x="30" y="250" width="500" height="20" fill="firebrick" />
<rect x="70" y="120" width="15" height="130" fill="firebrick" />
<rect x="170" y="120" width="15" height="130" fill="firebrick" />
<rect x="270" y="120" width="15" height="130" fill="firebrick" />
<rect x="370" y="120" width="15" height="130" fill="firebrick" />
<rect x="470" y="120" width="15" height="130" fill="firebrick" />
<rect x="238" y="230" width="80" height="20" fill="#7fffd4" stroke="black" stroke-width="1" />
<rect x="248" y="209" width="60" height="20" fill="#222d24" stroke="black" stroke-width="1" />
<rect x="256" y="188" width="45" height="20" fill="#ffc4c4" stroke="black" stroke-width="1" />
<rect x="261" y="167" width="34" height="20" fill="#222d24" stroke="black" stroke-width="1" />
<rect x="265" y="146" width="26" height="20" fill="#bbe200" stroke="black" stroke-width="1" />
<rect x="268" y="125" width="20" height="20" fill="#7fffd4" stroke="black" stroke-width="1" />
</svg>

After

Width:  |  Height:  |  Size: 1 KiB