zadania ktore byly pod reka

This commit is contained in:
acki02 2024-12-06 21:30:48 +01:00
commit 5dafc15833
21 changed files with 315 additions and 0 deletions

File diff suppressed because one or more lines are too long

19
zad_dom5/1_1/main.c Normal file
View File

@ -0,0 +1,19 @@
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fptr;
fptr = fopen("long_text.txt", "w");
fprintf(fptr, "0123456789");
fptr = freopen("long_text.txt","a",fptr);
for(int i = 0; i < 10000-1; i++)
{
fprintf(fptr, "0123456789");
}
fclose(fptr);
}

BIN
zad_dom5/1_1/textgen.exe Normal file

Binary file not shown.

63
zad_dom5/1_2/main.c Normal file
View File

@ -0,0 +1,63 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
int main()
{
//width, height, and bitcount are the key factors:
int32_t width = 64;
int32_t height = 64;
uint16_t bitcount = 24;//<- 24-bit bitmap
//take padding in to account
int width_in_bytes = ((width * bitcount + 31) / 32) * 4;
//total image size in bytes, not including header
uint32_t imagesize = width_in_bytes * height;
//this value is always 40, it's the sizeof(BITMAPINFOHEADER)
const uint32_t biSize = 40;
//bitmap bits start after headerfile,
//this is sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)
const uint32_t bfOffBits = 54;
//total file size:
uint32_t filesize = 54 + imagesize;
//number of planes is usually 1
const uint16_t biPlanes = 1;
//create header:
//copy to buffer instead of BITMAPFILEHEADER and BITMAPINFOHEADER
//to avoid problems with structure packing
unsigned char header[54] = { 0 };
memcpy(header, "BM", 2);
memcpy(header + 2 , &filesize, 4);
memcpy(header + 10, &bfOffBits, 4);
memcpy(header + 14, &biSize, 4);
memcpy(header + 18, &width, 4);
memcpy(header + 22, &height, 4);
memcpy(header + 26, &biPlanes, 2);
memcpy(header + 28, &bitcount, 2);
memcpy(header + 34, &imagesize, 4);
//prepare pixel data:
unsigned char* buf = malloc(imagesize);
for(int row = height - 1; row >= 0; row--)
{
for(int col = 0; col < width; col++)
{
buf[row * width_in_bytes + col * 3 + 0] = rand()%256;//blue
buf[row * width_in_bytes + col * 3 + 1] = rand()%256;//green
buf[row * width_in_bytes + col * 3 + 2] = rand()%256;//red
}
}
FILE *fout = fopen("test.bmp", "wb");
fwrite(header, 1, 54, fout);
fwrite((char*)buf, 1, imagesize, fout);
fclose(fout);
free(buf);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
zad_dom5/1_2/noisegen.exe Normal file

Binary file not shown.

63
zad_dom5/1_3/main.c Normal file
View File

@ -0,0 +1,63 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
int main()
{
//width, height, and bitcount are the key factors:
int32_t width = 64;
int32_t height = 64;
uint16_t bitcount = 24;//<- 24-bit bitmap
//take padding in to account
int width_in_bytes = ((width * bitcount + 31) / 32) * 4;
//total image size in bytes, not including header
uint32_t imagesize = width_in_bytes * height;
//this value is always 40, it's the sizeof(BITMAPINFOHEADER)
const uint32_t biSize = 40;
//bitmap bits start after headerfile,
//this is sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)
const uint32_t bfOffBits = 54;
//total file size:
uint32_t filesize = 54 + imagesize;
//number of planes is usually 1
const uint16_t biPlanes = 1;
//create header:
//copy to buffer instead of BITMAPFILEHEADER and BITMAPINFOHEADER
//to avoid problems with structure packing
unsigned char header[54] = { 0 };
memcpy(header, "BM", 2);
memcpy(header + 2 , &filesize, 4);
memcpy(header + 10, &bfOffBits, 4);
memcpy(header + 14, &biSize, 4);
memcpy(header + 18, &width, 4);
memcpy(header + 22, &height, 4);
memcpy(header + 26, &biPlanes, 2);
memcpy(header + 28, &bitcount, 2);
memcpy(header + 34, &imagesize, 4);
//prepare pixel data:
unsigned char* buf = malloc(imagesize);
for(int row = height - 1; row >= 0; row--)
{
for(int col = 0; col < width; col++)
{
buf[row * width_in_bytes + col * 3 + 0] = 0;//blue
buf[row * width_in_bytes + col * 3 + 1] = 0;//green
buf[row * width_in_bytes + col * 3 + 2] = 0;//red
}
}
FILE *fout = fopen("test.bmp", "wb");
fwrite(header, 1, 54, fout);
fwrite((char*)buf, 1, imagesize, fout);
fclose(fout);
free(buf);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
zad_dom5/1_3/noisegen.exe Normal file

Binary file not shown.

BIN
zad_dom5/2/apple.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 MiB

BIN
zad_dom5/2/apple.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

BIN
zad_dom5/2/apple.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

BIN
zad_dom5/2/apple.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

BIN
zad_dom5/2/kompresje.docx Normal file

Binary file not shown.

BIN
zad_dom5/3/entropia.docx Normal file

Binary file not shown.

17
zad_dom6/1/wizytowki.xml Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE card[
<!ELEMENT card (name, surname, email, phone, address)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT surname (#PCDATA)>
<!ELEMENT email (#PCDATA)>
<!ELEMENT phone (#PCDATA)>
<!ELEMENT address (#PCDATA)>
<!ELEMENT services (#PCDATA)>
]>
<card>
<name>Joe</name>
<surname>Doe</surname>
<email>joe.doe@mails.net</email>
<phone>555-0100</phone>
<address>Knowhere</address>
</card>

9
zad_dom6/2/plik_dtd.dtd Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<!ELEMENT znajomi (name, surname, email, phone, address, services+)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT surname (#PCDATA)>
<!ELEMENT email (#PCDATA)>
<!ELEMENT phone (#PCDATA)>
<!ELEMENT address (#PCDATA)>
<!ELEMENT services (#PCDATA)>

9
zad_dom6/2/wizytowki.xml Normal file
View File

@ -0,0 +1,9 @@
<!DOCTYPE znajomi SYSTEM "plik_dtd.dtd">
<znajomi>
<name>Joe</name>
<surname>Doe</surname>
<email>joe.doe@mails.net</email>
<phone>555-0100</phone>
<address>Knowhere</address>
<services>cleanup</services>
</znajomi>

67
zad_dom6/3/dodane_dtd.xml Normal file
View File

@ -0,0 +1,67 @@
<!DOCTYPE spis_powszechny[
<!ELEMENT spis_powszechny (date,address,person+)>
<!ELEMENT date (year, month,day)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT month (#PCDATA)>
<!ELEMENT day (#PCDATA)>
<!ELEMENT address (street, city, county, country, postalcode)>
<!ELEMENT street (#PCDATA|unit)*>
<!ELEMENT unit (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT county (#PCDATA)>
<!ELEMENT country (#PCDATA)>
<!ELEMENT postalcode (#PCDATA)>
<!ELEMENT person (name, age, gender)>
<!ELEMENT name (first, last, junior?)>
<!ELEMENT first (#PCDATA)>
<!ELEMENT last (#PCDATA)>
<!ELEMENT junior (#PCDATA)>
<!ELEMENT age (#PCDATA)>
<!ELEMENT gender (#PCDATA)>
<!ATTLIST spis_powszechny rachmistrz CDATA #REQUIRED>
<!ATTLIST person employed (fulltime|parttime) #IMPLIED>
<!ATTLIST person id CDATA #REQUIRED>
]>
<spis_powszechny rachmistrz="3163">
<date>
<year>2021</year>
<month>5</month>
<day>11</day>
</date>
<address>
<street>
Lane 111
<unit>4</unit>
</street>
<city>Big City</city>
<county>Greenwood</county>
<country>Ooo</country>
<postalcode>88-112</postalcode>
</address>
<person employed="fulltime" id="123098665">
<name>
<first>Miron</first>
<last>Baar</last>
<junior />
</name>
<age>39</age>
<gender>male</gender>
</person>
<person employed="parttime" id="020398665">
<name>
<first>Marion</first>
<last>Brug-Baar</last>
</name>
<age>36</age>
<gender>female</gender>
</person>
<person id="986650203">
<name>
<first>Barble</first>
<last>Baar</last>
</name>
<age>11</age>
<gender>male</gender>
</person>
</spis_powszechny>

56
zad_dom7/library.json Normal file
View File

@ -0,0 +1,56 @@
{
"library":{
"books":[
{
"title":"Library manual",
"author":"librarian",
"publication_year":1999
},
{
"title":"The Hobbit: There and Back Again",
"author":"J. R. R. Tolkien",
"publication_year":1937
},
{
"title":"Dunno",
"author":"Dude",
"publication_year":2000
},
{
"title":"What is this?",
"author":"Unknown",
"publication_year":1950
},
{
"title":"The book that doesn't exist",
"author":"Noone",
"publication_year":2137
},
{
"title":"???",
"author":"???",
"publication_year":1950
},
{
"title":"why am I doing this",
"author":"me",
"publication_year":2024
},
{
"title":"why am I doing this II: why oh why",
"author":"me",
"publication_year":2024
},
{
"title":"Encyclopedia of Rocks and Stones",
"author":"DRG Mission Control",
"publication_year":3000
},
{
"title":"Library manual, part 5",
"author":"librarian",
"publication_year":2000
}
]
}
}

11
zad_dom7/orders.csv Normal file
View File

@ -0,0 +1,11 @@
date;product;price per item;price per unit;amount
26.12.2006;pencil; $1,00 ;;5
20.04.2007;paperclips; $0,35 ;;250
09.11.2009;blank DVD; $3,00 ;;30
05.01.2011;5 cm steel nails;; $10,00 ;5kg
30.08.2011;notebook 50 pages; $3,50 ;;4
19.02.2014;fridge; $700,00 ;;1
14.11.2014;cat in a bag;;;?
06.11.2017;toster; $50,00 ;;1
17.09.2018;Blue ABS Filament; $29,99 ;;10
01.10.2020;Keys; $0,01 ;;1
1 date product price per item price per unit amount
2 26.12.2006 pencil $1,00 5
3 20.04.2007 paperclips $0,35 250
4 09.11.2009 blank DVD $3,00 30
5 05.01.2011 5 cm steel nails $10,00 5kg
6 30.08.2011 notebook 50 pages $3,50 4
7 19.02.2014 fridge $700,00 1
8 14.11.2014 cat in a bag ?
9 06.11.2017 toster $50,00 1
10 17.09.2018 Blue ABS Filament $29,99 10
11 01.10.2020 Keys $0,01 1