Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct statek{int,x,y; struct statek* nast;};
- typedef struct statek STATEK;
- STATEK *pierwszy;
- //pierwszy->x = 3;
- //pierwszy->y=5;
- //pierwszy->nast->x=7;
- //pierwszy->nast->y=8;
- Lista funkcja (Lista pierwszy, int x0, int y0)
- {
- int licznik = 0;
- double suma = 0;
- double srednia;
- Statek* pom = pierwszy;
- while (pom!=NULL)
- {
- suma = suma + sqrt((pom->x - x0)*(pom->x - x0) + (pom->y - y0)*(pom->y*y0));
- licznik++;
- pom = pom->nast;
- }
- srednia = suma/licznik;
- STATEK* nowa;
- STATEK* pom2 = nowa;
- pom = pierwszy;
- while (pom!=NULL)
- {
- if (sqrt((pom->x - x0)*(pom->x - x0) + (pom->y - y0)*(pom->y*y0)) <= srednia)
- {
- pom2 = malloc(sizeof(STATEK));
- *pom2 = *pom;
- pom2->nast=NULL;
- }
- pom=pom->nast;
- }
- pom = pierwszy;
- while (pom!=NULL)
- {
- if (sqrt((pom->x - x0)*(pom->x - x0) + (pom->y - y0)*(pom->y*y0)) > srednia)
- {
- pom2 = malloc(sizeof(STATEK));
- *pom2 = *pom;
- pom2->nast=NULL;
- }
- pom=pom->nast;
- }
- return nowa;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement