求,关于5个数据的处理程序有关问题

求高手指点,关于5个数据的处理程序问题

/*求五个数据p[5]的平均值, 及他们的各自与平均值的差t[5]*/
#include<stdio.h>
void main()
{ int i;
float p[5],t[5],he=0,junzhi;
while(1){ 
printf("please input the numbers:\n");
scanf("%f,%f,%f,%f,%f",&p[0],&p[1],&p[2],&p[3],&p[4]);
  for(i=0;i<5;i++)
{
  he=he+p[i]; /*这里有问题*/
}
  junzhi=he/5;
  for(i=0;i<5;i++)
  {
  t[i]=p[i]-junzhi; /*这里有问题*/
  }
  printf("he=%f,junzhi=%f,%f,%f,%f,%f\n",he,junzhi,t[0],t[1],t[2],t[3],t[4]);
}
}

编译器显示:

求五个数均值和差.cpp
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(5) : error C2018: unknown character '0xa3'
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(5) : error C2018: unknown character '0xac'
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(5) : error C2146: syntax error : missing ';' before identifier 't'
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(5) : error C2065: 't' : undeclared identifier
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(5) : error C2109: subscript requires array or pointer type
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(5) : error C2065: 'he' : undeclared identifier
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(5) : error C2065: 'junzhi' : undeclared identifier
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(11) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(16) : error C2109: subscript requires array or pointer type
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(16) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(16) : error C2106: '=' : left operand must be l-value
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(18) : error C2109: subscript requires array or pointer type
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(18) : error C2109: subscript requires array or pointer type
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(18) : error C2109: subscript requires array or pointer type
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(18) : error C2109: subscript requires array or pointer type
E:\C 语言工程文件\数据处理2\求五个数均值和差.cpp(18) : error C2109: subscript requires array or pointer type
执行 cl.exe 时出错.

数据处理2.exe - 1 error(s), 0 warning(s)


------解决方案--------------------
float p[5],t[5],he=0,junzhi;
你在这里用了个全角逗号,后面就都错了。
------解决方案--------------------
C/C++ code
float p[5],t[5],he=0,junzhi;//这句代码的第一个逗号,改成英文的

------解决方案--------------------
程序里的问题就是没有及时将he清零。
C/C++ code
/*求五个数据p[5]的平均值, 及他们的各自与平均值的差t[5]*/
#include<stdio.h>
void main()
{
    int i;
    float p[5],t[5],he=0,junzhi;
    while(1)
    {
        printf("please input the numbers:\n");
        scanf("%f,%f,%f,%f,%f",&p[0],&p[1],&p[2],&p[3],&p[4]);
        he=0;       //  每次循环时都应该把它清零
        for(i=0;i<5;i++)
        {
            he=he+p[i];
        }
        junzhi=he/5;
        for(i=0;i<5;i++)
        {
            t[i]=p[i]-junzhi;
        }
        printf("he=%f,junzhi=%f,%f,%f,%f,%f\n",he,junzhi,t[0],t[1],t[2],t[3],t[4]);
    }
}

------解决方案--------------------
LZ可以for循环输入输出啊,你这样用scanf和printf很累的