c++ - Can't understand wrong answer in graphing program -


there problem in have points on graph (~100 of them) , rotate amount, except 1 of them. tackle problem taking distances center of first set of points, , distances center of second set, then, after comparing them, 1 set not have matching distance--which wrong point.

    #include <iostream> #include <cmath> #include <math.h> using namespace std; int main() { int star1, star2; cin>>star1; int x1[star1], y1[star1]; (int i=0; i<star1; i++) {cin>>x1[i]>>y1[i];}  cin>>star2; int x2[star2], y2[star2]; (int i=0; i<star2; i++) {cin>>x2[i]>>y2[i];}  int d1[star1], d2[star2]; (int i=0; i<star1; i++) {d1[i]=sqrt(x1[i]*x1[i]+y1[i]*y1[i]);  d2[i]=sqrt(x2[i]*x2[i]+y2[i]*y2[i]); } int dis=0; //the ones furthest center gone  if (star1>star2)  {for (int i=0; i<(star1-star2); i++)  {if (d1[i]<d1[i+1])  {dis=i+1;} }   (int = dis; < star1; i++) {d1[dis] = d1[dis+1]; d1[star1-1] = 0;} }   else if (star2>star1)  {for (int i=0; i<(star2-star1); i++)  {if (d2[i]<d2[i+1])  {dis = i+1;} }  (int = dis; < star2; i++) {d2[dis] = d2[dis+1]; d2[star2-1] = 0;}  }  int one, two; (int begin=0; begin<star1; begin++) {  (int i=0; i<star2; i++)  {if (d1[begin]==d2[i])  {one=begin; two=i;  goto finish;}}   }   finish:   cout<<one<<" "<<two;   } 

the original problem: http://www.codeabbey.com/index/task_view/wandering-star wrong code, or wrong interpretation?

the first problem see approach assuming point of rotation origin. if set has been rotated different point?

also, seems me prompt @ link posted says second image slight rotations and slight shift first. imply point of rotation different in both sets. also, note problem statement suggests star near edge may leave image space. case need consideration.

try thinking how find point of rotation in each image. properties have, , there ways can use geometric properties isolate it? if able both points of rotation, able proceed suggested solution.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -