Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- /* zadanie 1
- struct pracownik
- {
- char imie [20];
- char nazwisko[30];
- int numer_pracownika;
- long long pesel;
- };
- int main( void )
- {
- struct pracownik p1 = { .imie = "Jan", .nazwisko = "Kowalski", .numer_pracownika = 4, .pesel = 92080212194};
- struct pracownik p2;
- printf("podaj imie pracownika\n");
- scanf("%s",&p2.imie);
- printf("podaj nazwisko pracownika\n");
- scanf("%s",&p2.nazwisko);
- printf("podaj identyfikator pracownika\n");
- scanf("%s",&p2.numer_pracownika);
- printf("podaj pesel pracownika\n");
- scanf("%s",&p2.pesel);
- return 0;
- }
- */
- /* zadanie 2
- struct zesp
- {
- double x;
- double y;
- };
- struct zesp z_add(struct zesp* A, struct zesp* B)
- {
- struct zesp zesp_result;
- zesp_result.x = A->x + B->x;
- zesp_result.y = A->y + B->y;
- printf("z1 + z2 = %f + %fi",zesp_result.x,zesp_result.y);
- return zesp_result;
- }
- struct zesp z_sub(struct zesp* A, struct zesp* B)
- {
- struct zesp zesp_result;
- zesp_result.x = A->x - B->x;
- zesp_result.y = A->y - B->y;
- printf("z1 - z2 = %f + %fi",zesp_result.x,zesp_result.y);
- return zesp_result;
- }
- struct zesp z_mul(struct zesp* A, struct zesp* B)
- {
- struct zesp zesp_result;
- zesp_result.x = (A->x * B->x) - (A->y * B->y);
- zesp_result.y = (A->x * B->y) + (A->y * B->x);
- printf("z1 * z2 = %f + %fi",zesp_result.x,zesp_result.y);
- return zesp_result;
- }
- struct zesp z_div(struct zesp* A, struct zesp* B)
- {
- struct zesp zesp_result;
- // aliasy
- double a = A->x;
- double b = A->y;
- double c = B->x;
- double d = B->y;
- if(B->x == 0 && B->y == 0)
- {
- return;
- }
- zesp_result.x = (a*c + b*d) / (c*c + d*d);
- zesp_result.y = (b*c - a*d) / (c*c + d*d);
- printf("z1 / z2 = %f + %fi",zesp_result.x,zesp_result.y);
- return zesp_result;
- }
- int main( void )
- {
- return 0;
- }
- */
- /* zadanie 3
- #include <time.h>
- const int tab_size = 100;
- struct point
- {
- int x, y;
- };
- void inicjalizuj_losowymi(struct point* tab)
- {
- int i;
- for(i = 0; i < tab_size; i++)
- {
- tab[i].x = (rand() % 201 - 100);
- tab[i].y = (rand() % 201 - 100);
- }
- }
- void display(struct point* tab)
- {
- int i;
- for(i = 0; i < tab_size; i++)
- {
- printf("x = %d, y = %d\n",tab[i].x,tab[i].y);
- }
- }
- struct point findFarthest(struct point* tab, struct point mPoint)
- {
- int i;
- double distance;
- double maxDistance = 0;
- double diffX,diffY;
- diffX = tab[0].x - mPoint.x;
- diffY = tab[0].y - mPoint.y;
- maxDistance = sqrt(diffX * diffX + diffY * diffY);
- struct point result;
- for(i = 0; i < tab_size; i++)
- {
- diffX = tab[i].x - mPoint.x;
- diffY = tab[i].y - mPoint.y;
- distance = sqrt(diffX * diffX + diffY * diffY);
- if(distance > maxDistance)
- {
- maxDistance = distance;
- result.x = tab[i].x;
- result.y = tab[i].y;
- }
- }
- printf("najdalszy od punktu(%d,%d) jest punkt z tablicy (%d,%d)",mPoint.x,mPoint.y,result.x,result.y);
- return result;
- }
- int main ( void )
- {
- srand(time(NULL));
- struct point points[tab_size];
- inicjalizuj_losowymi(points);
- display(points);
- struct point MPOINT = {0,0};
- findFarthest(points,MPOINT);
- return 0;
- }
- */
- /* zadanie 4
- struct extra_point
- {
- double x;
- char start;
- char end;
- short y;
- int z;
- };
- int main( void )
- {
- printf("%d",sizeof(struct extra_point));
- return 0;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement