Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- typedef struct kartezjanskie
- {
- double x;
- double y;
- }kart;
- typedef struct biegunowe
- {
- double r;
- double f;
- }bieg;
- int wybor()
- {
- int rodzaj;
- printf("Chcesz wprowadzic wsp kartezjanskie i zamienic na wsp biegunowe, jesli tak nacisnij 1\n");
- printf("Chcesz wprowadzic wsp biegunowe i zamienic na wsp kartezjanskie, jesli tak nacisnij 2\n");
- scanf("%d", &rodzaj);
- return rodzaj;
- }
- void wpisywanie(kart* s,bieg* b,int rodzaj)
- {
- if(rodzaj == 1)
- {
- printf("Podaj X");
- scanf("%lf", &s->x);
- printf("Podaj Y");
- scanf("%lf", &s->y);
- b->f=atan(s->y/s->x);
- b->r=s->x/cos(b->f);
- }
- else if(rodzaj ==2)
- {
- printf("Podaj R");
- scanf("%lf", &b->r);
- printf("Podaj f");
- scanf("%lf", &b->f);
- s->x=b->r*cos(b->f);
- s->y=b->r*sin(b->f);
- }
- else
- {
- printf("Podales zla wartosc operacji\n");
- }
- }
- int main()
- {
- kart wsp;
- bieg wsx;
- int rodzaj;
- rodzaj=wybor();
- wpisywanie(&wsp,&wsx,rodzaj);
- printf("x=%lf y=%lf f=%lf r=%lf",wsp.x,wsp.y,wsx.r,wsx.f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement