Advertisement
olekturbo

Untitled

Nov 20th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4.  
  5. struct point
  6. {
  7. int a,b;
  8. };
  9.  
  10. point *wsk;
  11. int wielkosc;
  12.  
  13. int distant(point *wsk, int wielkosc)
  14. {
  15. unsigned int buf;
  16.  
  17. buf=wsk[0].a*wsk[0].a+wsk[0].b*wsk[0].b;
  18. for(int i=0; i<wielkosc; i++)
  19. {
  20. if(buf>=wsk[i].a*wsk[i].a+wsk[i].b*wsk[i].b)
  21. {
  22. buf=wsk[i].a*wsk[i].a+wsk[i].b*wsk[i].b;
  23. }
  24. }
  25.  
  26.  
  27. return (wsk[buf].a*wsk[buf].a+wsk[buf].b*wsk[buf].b);
  28.  
  29.  
  30. }
  31.  
  32. int main()
  33. {
  34. point *wsk=new point[wielkosc];
  35. fstream plik;
  36. plik.open("in.txt", ios::in);
  37.  
  38.  
  39.  
  40. cout<<endl;
  41.  
  42. for(int i=0; i<wielkosc; i++)
  43. {
  44. while(plik.good())
  45. {
  46. plik>>wsk[wielkosc].a;
  47. plik>>wsk[wielkosc].b;
  48. cout<<wsk[wielkosc].a<<" "<<wsk[wielkosc].b<<endl;
  49. }
  50.  
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement