Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct punct{int x,y;};
- void citire (punct *p)
- {
- printf("\nx=");
- scanf("%d",&p->x);
- printf("\ny=");
- scanf("%d",&p->y);
- }
- void afisare(punct *p)
- {
- printf("\np.x=%d",p->x);
- printf("\np.y=%d",p->y);
- }
- double distanta(punct &a,punct &b)
- {
- double dist;
- dist=sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
- return dist;
- }
- int main ()
- {
- punct p1,p2,pct[N],*pp;
- int i,dim;
- double dist;
- printf("Citire p1:\n");
- citire(&p1);
- citire(&p2);
- afisare(&p1);
- afisare(&p2);
- printf("\nDistanta=%.2f",distanta(p1,p2));
- printf("dim=");scanf("%d",&dim);
- pp=new punct[dim];
- printf("Coordonatele sunt: \n");
- for(i=0;i<dim;i++)
- {
- citire(&pp[i]);
- afisare(&pp[i]);
- distanta(pp[i],pp[i+1]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement