{% blockquote 本文出自 http://svtter.github.io svtter.github.io %}
本文可以随意转载,但是转载请保留本信息.
做CDMA简单的接收处理。
文件
input:
-1 -1 -1 1 1 -1 1 1 -1 -1 1 -1 1 1 1 -1 -1 1 -1 1 1 1 -1 -1 -1 1 -1 -1 -1 -1 -1 1
new.c:
#include <stdio.h> #include <math.h> #define M 8 const int b[] = {-1, 1, -3, 1, -1, -3, 1, 1}; void show(int a[]) { int i; for(i = ; i < M; i++) printf("%5d", a[i]); puts(""); } int main() { int a[M]; int i; freopen('input', 'r', stdin); while(1) { for(i = ; i < M; i++) { scanf("%d", &a[i]); } show(a); int sum = ; for(i = ; i < M; i++) sum += a[i] * b[i]; printf("%d\n", sum/M); } return ; }