1.c vector Դ??
2.c 中vector的用法详解
c vector Դ??
//只写了二维向量的,如果多维向量,mvc wcf 源码继续扩展就可以了
#include <stdio.h>
#include <math.h>
typedef struct vector{
float x;
float y;
}Vector;
float norm(Vector v){
return sqrt(v.x*v.x+v.y*v.y);
}
float dotmuti(Vector u,遥感matlab源码 Vector v){
return u.x*v.y+u.y*v.x;
}
// a's project on b
Vector project(Vector a, Vector b){
Vector temp;
float c;
if (norm(b) > 0)
c = dotmuti(a,b) / norm(b) / norm(b);
else
c = 0;
temp.x = b.x * c;
temp.y = b.y * c;
return temp;
}
int main()
{
Vector a;
Vector b;
// input vector a
printf("Pls input the first vector x and y\n");
printf("x:\n");
scanf("%f",&a.x);
printf("y:\n");
scanf("%f",&a.y);
//input vector b;
printf("Pls input the second vector x and y\n");
printf("x:\n");
scanf("%f",&b.x);
printf("y:\n");
scanf("%f",&b.y);
//output the vector
printf("Vector(%f, %f)'s projection on Vector(%f, %f) is: Vector(%f, %f).\n", a.x, a.y, b.x,b.y,project(a,b).x,project(a,b).y);
}
c 中vector的用法详解
c中vector的用法详解如下:
vector(向量):C中的一种数据结构,确切的怎样修改源码说是一个类。它相当于一个动态的剑3源码数组,当程序员无法知道自己需要的php 打印源码数组的规模多大时,用其来解决问题可以达到最大节约空间的目的。
2024-11-23 12:35
2024-11-23 12:26
2024-11-23 11:59
2024-11-23 11:32
2024-11-23 11:31
2024-11-23 10:56
2024-11-23 10:50
2024-11-23 10:32