?? dotp4.c
字號:
//Dotp4.c Multiplies two arrays, each array with 4 numbers
int dotp(short *a, short *b, int ncount); //function prototype
#include <stdio.h> //for printf
#include "dotp4.h" //data file of numbers
#define count 4 //# of data in each array
short x[count] = {x_array}; //declaration of 1st array
short y[count] = {y_array}; //declaration of 2nd array
main()
{
int result = 0; //result sum of products
result = dotp(x,y,count); //call dotp function
printf("result = %d (decimal) \n", result); //print result
}
int dotp(short *a, short *b, int ncount) //dot product function
{
int sum = 0; //init sum
int i;
for (i = 0; i < ncount; i++)
sum += a[i] * b[i]; //sum of products
return(sum); //return sum as result
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -