求助高手帮我看看!程序运行不对!
--------------------Configuration: PROG - Win32 Debug--------------------Compiling...
PROG.C
c:\wexam\00000000\prog.c(21) : error C2065: 'totcnt' : undeclared identifier
c:\wexam\00000000\prog.c(22) : error C2065: 'totpjz' : undeclared identifier
Error executing cl.exe.
PROG.exe - 2 error(s), 0 warning(s)
----------------------------------------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#define MAXNUM 200
int xx[MAXNUM] ;
int totNum = 0 ;
int totCnt = 0 ;
double totPjz = 0.0 ;
int ReadDat(void) ;
void Writedat(void) ;
void CalValue(void)
{
int i,j;
int data;
for(i=0;i<MAXNUM;i++)
if(xx[i]>0);
{
totNum++;
data=xx[i]>>1;
if(data%2!=0)
{
totcnt++;
totpjz+=xx[i];
}
}
totpjz/=totcnt;
}
void main()
{
int i ;
system("CLS");
for(i = 0 ; i < MAXNUM ; i++)
xx[i] = 0 ;
if (ReadDat ())
{
printf("数据文件IN11.DAT不能打开!\007\n");
return ;
}
CalValue() ;
printf("文件IN11.DAT中共有正整数= %d 个\n", totNum);
printf("符合条件的正整数的个数= %d 个\n", totCnt);
printf("平均值=%.2lf\n", totPjz);
Writedat() ;
}
int ReadDat(void)
{
FILE *fp;
int i = 0 ;
if((fp = fopen ("IN11.DAT", "r")) == NULL)
return 1 ;
while(! feof(fp))
{
fscanf(fp, "%d,", &xx[i++]) ;
}
fclose(fp) ;
return 0 ;
}
void Writedat(void)
{
FILE *fp;
fp = fopen("OUT11.DAT", "w") ;
fprintf(fp, "%d\n%d\n%.2lf\n", totNum, totCnt, totPjz) ;
fclose(fp) ;
}
---------------------------------------------------------------------------------------------------------
运行结果
文件IN11.DAT中共有正整数=0个
符合条件的正整数的个数=0个
平均值=0.00
perss any key to contine