08/10/28 11:17:04
>>857
課題2
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* (x,y)-平面の点を座標で表す構造体 */
struct Point{
double x, y;
};
/* 要素を代入する関数 */
void input_point(struct Point data[], int i)
{
printf("Input Point p[%d].x: ", i);
scanf("%lf", &data[i].x);
printf("Input Point p[%d].y: ", i);
scanf("%lf", &data[i].y);
}
/* 長さを求める関数 */
double length_vector2(struct Point data[]){
return sqrt(pow(data[0].x - data[1].x, 2.0) + pow(data[0].y - data[1].y, 2.0));
}