C51的一个简单程序总是有问题?请问!
编译没错误,运行出现错误提示:*** error 65: access violation at I:0x81 : no 'write' permission,串行口没有输出。请问大家问题如何解决?为什么?程序附下中:
#include <stdio.h>
#include <reg51.h>
float average(array,n)
float array[];
int n;
{
int i;
float aver,sum;
sum=array[0];
for(i=1;i <n;i++)
sum=sum+array[i];
aver=sum/n;
return(aver);
}
void main(){
float pot_1[5]={99.9,88.8,77.7,66.6,0};
float pot_2[10]={11.1,22.2,33.3,44.4,55.5,99.9,88.8,77.7,66.6,0};
SCON=0x52;
TMOD=0x20;
TCON=0x69;
TH1=0x0F3;
printf("the average of A is %6.2f\n",average(pot_1,5));
printf("the average of B is %6.2f\n",average(pot_2,10));
}
发表时间:2003年9月9日19:56:00