// Use the ">>" operator to calculate the average value of an array instead of using buf
#include "stdio.h"
typedef unsigned char uint8_t;
#define ARRAY_N (200)
void main(void)
{
uint8_t array[ARRAY_N] ;
uint8_t i;
uint8_t aver = 0;
for(i = 0; i < ARRAY_N; i++)
{
array[i] = 64;
}
for(i = 0; i < ARRAY_N; i++)
{
aver = aver - (aver>>5) + (array[i] >> 5); // calculat the average
}
printf("\nhello Lihua Long, good job!!\n");
printf("The aver is : %d\n",aver);
}
// PS E:\006-Programing\007-c> gcc -o main main.c
// PS E:\006-Programing\007-c> ./main
// hello Lihua Long, good job!!
// The aver is : 64
// PS E:\006-Programing\007-c>
新型均值计算算法Use the “>>“ operator to calculate the average value of an array instead of using buf
于 2023-12-23 23:59:57 首次发布