-(void)calculateLength:(int)x1 andY1:(int)y1 andX2:(int)x2 andY2:(int)y2
{
int length;
length = sqrt( pow((x2 - x1),2) + pow((y2 - y1), 2) );
NSLog(@"两点的长度为%d",length);
}
本文介绍了一个简单的Objective-C方法,用于计算二维平面上两点之间的直线距离。该方法利用勾股定理,通过输入两点的坐标来计算它们之间的距离。
-(void)calculateLength:(int)x1 andY1:(int)y1 andX2:(int)x2 andY2:(int)y2
{
int length;
length = sqrt( pow((x2 - x1),2) + pow((y2 - y1), 2) );
NSLog(@"两点的长度为%d",length);
}
6208
693
1071

被折叠的 条评论
为什么被折叠?