[ create a new paste ] login | about

Link: http://codepad.org/1JELk1gk    [ raw code | fork ]

C, pasted on Oct 19:
#include<stdio.h>
#include<math.h>
    struct toado
    {
	float x;
	float y;
	};
	struct diem
	{
		toado diemA, diemB;		
	}doan;
	void nhaptoado( toado &p)
	{
		
		scanf("%f\n", &p.x);
		scanf("%f\n", &p.y);
		
	}
	void toadodoanthang( diem &tg)
	{
		nhaptoado(tg.diemA);
		nhaptoado(tg.diemB);
	}
	void xuattoado( diem &tg)
	{
		float k;
		printf("toa do diem A %f;%f\n", tg.diemA.x, tg.diemA.y);
		printf("toa do diem B %f;%f\n", tg.diemB.x, tg.diemB.y);
		k = sqrt(pow(tg.diemA.x - tg.diemB.x, 2) + pow(tg.diemA.y - tg.diemB.y, 2));
		printf("do dai doan thang la %f\n", k);
	}
	void main ()
	{		
	        diem tg; 
		toado p;
		nhaptoado(p);
		toadodoanthang(tg);
		xuattoado(tg);		
	}


Create a new paste based on this one


Comments: