Problem D: 编程题B-向量的数量积

来源:互联网 发布:交换机的端口镜像 编辑:程序博客网 时间:2024/04/29 06:55

Problem D: 编程题B-向量的数量积

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 164  Solved: 148

Description

已知两个非零向量a=(x1,y1),b=(x2,y2),则有a·b=x1x2+y1y2,即两个向量的数量积等于它们对应坐标的乘积的和。

Input

输入x1,y1,x2,y2的值

Output

两个向量的数量积

Sample Input

-1 2 3 -4

Sample Output

-11

HINT
#include <stdio.h> #include <stdlib.h> struct zuobiao {     int hong,zong; }; int main() {     struct zuobiao zuo[2];     for(int i=0;i<2;i++)         scanf("%d%d",&zuo[i].hong,&zuo[i].zong);         printf("%d\n",(zuo[1].hong*zuo[0].hong)+(zuo[1].zong*zuo[0].zong)); return 0; } 

0 0
原创粉丝点击