c++计算点与原点的距离和角度

img

img


请问这个怎么回事好像有问题,另外角度怎么弄,我不会用角度,麻烦了

可参考:https://zhidao.baidu.com/question/878426893723471852.html

#include <bits/stdc++.h>
using namespace std;
  
  int main(){
      double x,y;
      scanf("%lf %lf",&x,&y);
      double distance = sqrt(x * x + y * y);
      double angle = 360 - fabs(atan2(y,x)/(2*acos(-1))*360);
      printf("%.3lf %.3lf\n", distance, angle);
  }

#define _CRT_SECURE_NO_WARNINGS
#include "stdio.h"
#include "math.h"
int main(void) {

  double x, y, r, theta;
  scanf("%lf, %lf", &x, &y);
  r = sqrt(x * x + y * y);
  theta = acos(x / r)*180.0/3.1415926;
  printf("%lf %lf\n", r, theta);
  return 0;
}