This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F5529数组计算



这样一组代码:

while(n < 36){
     r = r + value[n]*cos_50Hz[n];
     i = i - value[n]*sin_50Hz[n];
     n++;
}

sin_50Hz[n]和cos_50Hz[n]都是定义为const float型的数组,数组提前初始化,值为sin10°,sin20°,...,sin360°,和cos10°,cos20°,...,cos360°,数组长度为36。r和i都是定义为double型,初始值为1。n为int型,初始化为0. value是const int型,长度为36, 所有值均为100

就这样一组代码,却得不出來结果,当循环结束的时候,r和i的值又重新变成0,这是为什么?