build Program C i need help with this program I dont know ho

build Program C++. i need help with this program

I don\'t know how to upload the text file here, so I copied and pasted it below. Thank you so much

2 5 2 8 5 2
9 0 0 1 3 0
0 8 8 9 6 3
3 9 1 8 5 2
1 4 10 0 0 9
9 8 1 3 6 8
9 10 7 3 2 5
4 8 1 4 10 6
0 0 5 8 5 9
4 1 3 9 1 9
8 5 1 10 5 8
4 1 10 3 2 0
2 0 2 4 6 10
10 7 10 10 2 8
4 10 8 1 3 8
5 5 7 6 6 2
4 3 7 4 2 6
1 8 9 5 4 7
5 4 0 5 4 0
1 8 6 2 10 7
1 1 8 4 5 5
3 5 1 2 0 5
4 7 3 9 0 3
7 3 2 0 0 7
7 5 6 4 9 7
3 4 3 3 9 2
7 1 0 3 0 2
9 8 2 4 10 4
1 10 1 6 0 5
3 5 9 3 4 1
9 5 7 9 4 6
1 1 3 4 7 8
0 3 7 8 10 7
0 8 5 10 7 8
4 1 7 7 7 3
5 3 1 4 4 10
7 7 0 10 3 9
4 5 6 5 2 2
10 8 4 1 9 0
10 0 6 10 2 3
2 10 8 8 4 4
7 1 5 2 1 10
0 6 1 9 0 0
3 7 10 0 5 3
2 0 6 6 6 10
7 5 6 5 8 9
8 2 1 9 1 3
7 5 10 3 0 10
5 6 1 1 3 5
1 0 0 0 9 1
3 7 6 8 9 9
6 9 2 1 6 8
5 2 10 5 1 8
0 9 0 8 7 8
5 10 10 0 9 1
4 9 4 7 0 4
8 8 0 10 3 8
8 9 7 5 6 0
1 9 3 10 7 4
9 7 4 5 1 5
9 7 0 9 8 1
6 3 9 0 1 3
7 4 3 7 9 4
1 4 7 6 8 6
9 4 1 3 3 6
6 3 8 6 3 0
0 8 10 3 9 7
3 9 10 0 2 6
2 2 3 4 4 9
8 9 9 4 3 4
9 9 4 10 0 6
1 3 3 10 5 7
10 7 9 5 0 9
6 3 5 7 5 3
0 7 10 10 9 3
8 2 1 9 6 8
2 7 1 1 8 1

The distance between two points in 3-space is given by the formula: y3) In C++, the std::sqrt() function is defined in

Solution

#include<bits/stdc++.h>
using namespace std;

bool readPoints(ifstream& ifs,int p1[],int p2[],int sz)
{
   int x1,x2,x3,y1,y2,y3;
   int i=0,j=0;
while(ifs>>x1>>x2>>x3>>y1>>y2>>y3)
   {
      
       float dis=sqrt((x1-y1)*(x1-y1)+(x2-y2)*(x2-y2)+(x3-y3)*(x3-y3));
           cout<<\"Points read :\"<<x1<<\" \"<<x2<<\" \"<<x3<<\" \"<<y1<<\" \"<<y2<<\" \"<<y3<<\" \"<<endl;


       if(dis>10)
       {
           p1[i++]=x1;
       p1[i++]=x2;
       p1[i++]=x3;

       p2[j++]=y1;
       p2[j++]=y2;
       p2[j++]=y3;
       sz++;
       cout<<\"Points with distance greater than 10. :\"<<x1<<\" \"<<x2<<\" \"<<x3<<\" \"<<y1<<\" \"<<y2<<\" \"<<y3<<\" \"<<endl;

       }

   }


   return true;
}

int main(int argc, char const *argv[])
{
   ifstream f(\"input.txt\");
   int p1[100],p2[100];
   int size=0;

   int x1,x2,x3,y1,y2,y3;
   readPoints(f,p1,p2,size);

  
   return 0;
}

=======================================

Output:

akshay@akshay-Inspiron-3537:~/Chegg$ g++ sqe.cpp
akshay@akshay-Inspiron-3537:~/Chegg$ ./a.out
Points read :2 5 2 8 5 2
Points read :9 0 0 1 3 0
Points read :0 8 8 9 6 3
Points with distance greater than 10. :0 8 8 9 6 3
Points read :3 9 1 8 5 2
Points read :1 4 10 0 0 9
Points read :9 8 1 3 6 8
Points read :9 10 7 3 2 5
Points with distance greater than 10. :9 10 7 3 2 5
Points read :4 8 1 4 10 6
Points read :0 0 5 8 5 9
Points with distance greater than 10. :0 0 5 8 5 9
Points read :4 1 3 9 1 9
Points read :8 5 1 10 5 8
Points read :4 1 10 3 2 0
Points with distance greater than 10. :4 1 10 3 2 0
Points read :2 0 2 4 6 10
Points with distance greater than 10. :2 0 2 4 6 10
Points read :10 7 10 10 2 8
Points read :4 10 8 1 3 8
Points read :5 5 7 6 6 2
Points read :4 3 7 4 2 6
Points read :1 8 9 5 4 7
Points read :5 4 0 5 4 0
Points read :1 8 6 2 10 7
Points read :1 1 8 4 5 5
Points read :3 5 1 2 0 5
Points read :4 7 3 9 0 3
Points read :7 3 2 0 0 7
Points read :7 5 6 4 9 7
Points read :3 4 3 3 9 2
Points read :7 1 0 3 0 2
Points read :9 8 2 4 10 4
Points read :1 10 1 6 0 5
Points with distance greater than 10. :1 10 1 6 0 5
Points read :3 5 9 3 4 1
Points read :9 5 7 9 4 6
Points read :1 1 3 4 7 8
Points read :0 3 7 8 10 7
Points with distance greater than 10. :0 3 7 8 10 7
Points read :0 8 5 10 7 8
Points with distance greater than 10. :0 8 5 10 7 8
Points read :4 1 7 7 7 3
Points read :5 3 1 4 4 10
Points read :7 7 0 10 3 9
Points with distance greater than 10. :7 7 0 10 3 9
Points read :4 5 6 5 2 2
Points read :10 8 4 1 9 0
Points read :10 0 6 10 2 3
Points read :2 10 8 8 4 4
Points read :7 1 5 2 1 10
Points read :0 6 1 9 0 0
Points with distance greater than 10. :0 6 1 9 0 0
Points read :3 7 10 0 5 3
Points read :2 0 6 6 6 10
Points read :7 5 6 5 8 9
Points read :8 2 1 9 1 3
Points read :7 5 10 3 0 10
Points read :5 6 1 1 3 5
Points read :1 0 0 0 9 1
Points read :3 7 6 8 9 9
Points read :6 9 2 1 6 8
Points read :5 2 10 5 1 8
Points read :0 9 0 8 7 8
Points with distance greater than 10. :0 9 0 8 7 8
Points read :5 10 10 0 9 1
Points with distance greater than 10. :5 10 10 0 9 1
Points read :4 9 4 7 0 4
Points read :8 8 0 10 3 8
Points read :8 9 7 5 6 0
Points read :1 9 3 10 7 4
Points read :9 7 4 5 1 5
Points read :9 7 0 9 8 1
Points read :6 3 9 0 1 3
Points read :7 4 3 7 9 4
Points read :1 4 7 6 8 6
Points read :9 4 1 3 3 6
Points read :6 3 8 6 3 0
Points read :0 8 10 3 9 7
Points read :3 9 10 0 2 6
Points read :2 2 3 4 4 9
Points read :8 9 9 4 3 4
Points read :9 9 4 10 0 6
Points read :1 3 3 10 5 7
Points with distance greater than 10. :1 3 3 10 5 7
Points read :10 7 9 5 0 9
Points read :6 3 5 7 5 3
Points read :0 7 10 10 9 3
Points with distance greater than 10. :0 7 10 10 9 3
Points read :8 2 1 9 6 8
Points read :2 7 1 1 8 1

build Program C++. i need help with this program I don\'t know how to upload the text file here, so I copied and pasted it below. Thank you so much 2 5 2 8 5 2
build Program C++. i need help with this program I don\'t know how to upload the text file here, so I copied and pasted it below. Thank you so much 2 5 2 8 5 2
build Program C++. i need help with this program I don\'t know how to upload the text file here, so I copied and pasted it below. Thank you so much 2 5 2 8 5 2
build Program C++. i need help with this program I don\'t know how to upload the text file here, so I copied and pasted it below. Thank you so much 2 5 2 8 5 2

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site