小区水电管理系统,有很多错误,求指点
#include<stdio.h>#include<stdlib.h>
#include<string.h>
#define N 100
#define w 1.5
#define e 0.5
typedef struct sdf
{
int number; //住户门牌号
char name; //住户姓名
double sa,da; //用水(吨),用电(度)
double sf,df; //水费,电费
char time; //收费时间
} SDF;
void AdddataFunc();
void StatisdataFunc();
void SortdataFunc();
void DeletedataFunc();
void QuerydataFunc();
void ModifdataFunc();
void CaldataFunc();
void SavedataFunc();
int main()
{
int select;
scanf("%d",&select);
switch(select)
{
case 1:
AdddataFunc(); break; //添加
case 2:
StatisdataFunc(); break; //统计
case 3:
SortdataFunc(); break; //排序
case 4:
DeletedataFunc();break; //删除
case 5:
QuerydataFunc(); break; //查询
case 6:
ModifdataFunc(); break; //修改
case 7:
Exit(0); //退出
}
}
void display(void)
{
system("cls"); //清屏
printf("欢迎使用住户水电费管理系统\n");
printf("在本系统中欲执行某功能请按相应数字\n");
printf("1 添加\n");
printf("2 统计\n");
printf("3 排序\n");
printf("4 删除\n");
printf("5 查询\n");
printf("6 修改\n");
printf("7 退出\n");
}
void SavedataFunc()
{
FILE *fp;
fp=fopen("Data.txt","w") ;
int i,j;
for(i=0;i<N;i++)
{
fscanf(fp,"%d%d%d%s",(p+i)-number,(p+i)-name,(p+i)-sf);
for(j=0;j<100;j++)
{
fscanf(fp,"%d%s%d",(p+i)-sa,(p+i)-sd,(p+i)-df,(p+i)-time);
}
}
fclose(fp);
}
void AdddataFunc()
{
int i,j;
SD sd;
printf("请输入新用户信息");
system ("cls");
for(i=0;i<N;i++)
{
printf("\n\t\tnumber:");
scanf("%d",sd.number);
(p+i)-number=sd.number;
printf("\n\t\tname");
scanf("%d",sd.name);
stcpy((p+i)-name,sd.name);
for(i=0;j<100;j++)
{
printf("\n\t\tsa:");
scanf("%d",sd.sa[j]);
(p+i)-sa=sd.sa;
printf("\n\t\tsa:");
scanf("%d",sd.da[j]);
(p+i)-da=sd.da;
printf("\n\t\ttime");
scanf("%d",sd.time);
stcpy((p+i)-time,sd.time);
}
printf("\n登记完毕!\n"); break;
}
SavedataFunc();
}
void SortdataFunc()
{
int i,j;
SD t;
for(i=0;i<N-1;i++)
{
for(j=0;j<N;j++)
{
if((p+i)-number<(p+j)-number)
{
t=(p+i);
(p+i)=(p+j);
(p+j)=t;
}
}
}
SavadataFunc();
}
void QuerydataFunc()
{
int i,j,n;
SD sd;
system("cls");
puts("\t\t\t 查询\n");
puts("\t\t\t* *\n");
puts("\t\t\t 1.住户门牌号\n");
puts("\t\t\t 2.户主姓名\n");
puts("\t\t\t 3.日期\n");
puts("\t\t\t\n");
printf("你想通过第几种方式查询?\b\b") ;
scanf("%d",&n);
switch(n)
{
case 1:
{
printf("住户门牌号:");
scanf("%",sd.number);
for(i=0;i<N;i++)
{
if((p+i)-number=sd.number)break;
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
for(j=0;j<100;j++)
{
printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
}
}
}break;
case 2:
{
printf("姓名:");
scanf("%s",sd.name);
for(i=0;i<N;i++)
{
if(strcmp((p+i)-name=sd.name)==0)break;
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
for(j=0;j<100;j++)
{
printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
}
}
}break;
case 3:
{
printf("日期:");
scanf("%s".sd.time);
for(i=0;i<N;i++)
{
if(strcmp((p+i)-name=sd.name)==0)break;
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
for(j=0;j<100;j++)
{
printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
}
}
}break;
}
}
void DeleteFunc()
{
int i,j,m;
printf("删除住户门牌号:[]\b\b");
scanf("%d",&m);
for(i=0;i<N;i++)
{
if((p+i)-number==0)
{
strcpy((p+i)-name,(p+j+1)-name);
(p+i)-sf=(p+i+1)-sf;
}
}
for(j=0;j<100;j++)
{
(p+i)-sd[j]=(p+i+1)-sd[j+1];
(p+i)-df=(p+i+1)-df[j+1];
strcpy((p+i)-time[j],(p+i+1)-time[j+1]);
}
SavadataFunc();
}
编译单个文件...
--------
- 文件名: C:\Users\zqm\Documents\未命名1.cpp
- 编译器名: TDM-GCC 4.9.2 64-bit Release
处理 C++ 源文件...
--------
- C++ 编译器: E:\Program Files (x86)\Dev-Cpp\MinGW64\bin\g++.exe
- 命令: g++.exe "C:\Users\zqm\Documents\未命名1.cpp" -o "C:\Users\zqm\Documents\未命名1.exe" -I"E:\Program Files (x86)\Dev-Cpp\MinGW64\include" -I"E:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\include" -I"E:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include" -I"E:\Program Files (x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++" -L"E:\Program Files (x86)\Dev-Cpp\MinGW64\lib" -L"E:\Program Files (x86)\Dev-Cpp\MinGW64\x86_64-w64-mingw32\lib" -static-libgcc
C:\Users\zqm\Documents\未命名1.cpp:140:5: error: stray '\243' in program
printf("住户门牌号:");
^
C:\Users\zqm\Documents\未命名1.cpp:140:5: error: stray '\273' in program
C:\Users\zqm\Documents\未命名1.cpp: In function 'int main()':
C:\Users\zqm\Documents\未命名1.cpp:42:9: error: 'Exit' was not declared in this scope
Exit(0); //退出
^
C:\Users\zqm\Documents\未命名1.cpp: In function 'void SavedataFunc()':
C:\Users\zqm\Documents\未命名1.cpp:66:24: error: 'p' was not declared in this scope
fscanf(fp,"%d%d%d%s",(p+i)-number,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:66:29: error: 'number' was not declared in this scope
fscanf(fp,"%d%d%d%s",(p+i)-number,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:66:42: error: 'name' was not declared in this scope
fscanf(fp,"%d%d%d%s",(p+i)-number,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:66:53: error: 'sf' was not declared in this scope
fscanf(fp,"%d%d%d%s",(p+i)-number,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:69:27: error: 'sa' was not declared in this scope
fscanf(fp,"%d%s%d",(p+i)-sa,(p+i)-sd,(p+i)-df,(p+i)-time);
^
C:\Users\zqm\Documents\未命名1.cpp:69:36: error: 'sd' was not declared in this scope
fscanf(fp,"%d%s%d",(p+i)-sa,(p+i)-sd,(p+i)-df,(p+i)-time);
^
C:\Users\zqm\Documents\未命名1.cpp:69:45: error: 'df' was not declared in this scope
fscanf(fp,"%d%s%d",(p+i)-sa,(p+i)-sd,(p+i)-df,(p+i)-time);
^
C:\Users\zqm\Documents\未命名1.cpp:69:54: error: 'time' was not declared in this scope
fscanf(fp,"%d%s%d",(p+i)-sa,(p+i)-sd,(p+i)-df,(p+i)-time);
^
C:\Users\zqm\Documents\未命名1.cpp: In function 'void AdddataFunc()':
C:\Users\zqm\Documents\未命名1.cpp:78:2: error: 'SD' was not declared in this scope
SD sd;
^
C:\Users\zqm\Documents\未命名1.cpp:84:14: error: 'sd' was not declared in this scope
scanf("%d",sd.number);
^
C:\Users\zqm\Documents\未命名1.cpp:85:4: error: 'p' was not declared in this scope
(p+i)-number=sd.number;
^
C:\Users\zqm\Documents\未命名1.cpp:85:9: error: 'number' was not declared in this scope
(p+i)-number=sd.number;
^
C:\Users\zqm\Documents\未命名1.cpp:88:15: error: 'name' was not declared in this scope
stcpy((p+i)-name,sd.name);
^
C:\Users\zqm\Documents\未命名1.cpp:88:27: error: 'stcpy' was not declared in this scope
stcpy((p+i)-name,sd.name);
^
C:\Users\zqm\Documents\未命名1.cpp:93:10: error: 'sa' was not declared in this scope
(p+i)-sa=sd.sa;
^
C:\Users\zqm\Documents\未命名1.cpp:96:10: error: 'da' was not declared in this scope
(p+i)-da=sd.da;
^
C:\Users\zqm\Documents\未命名1.cpp:99:19: error: 'time' was not declared in this scope
stcpy((p+i)-time,sd.time);
^
C:\Users\zqm\Documents\未命名1.cpp: In function 'void SortdataFunc()':
C:\Users\zqm\Documents\未命名1.cpp:108:2: error: 'SD' was not declared in this scope
SD t;
^
C:\Users\zqm\Documents\未命名1.cpp:113:7: error: 'p' was not declared in this scope
if((p+i)-number<(p+j)-number)
^
C:\Users\zqm\Documents\未命名1.cpp:113:12: error: 'number' was not declared in this scope
if((p+i)-number<(p+j)-number)
^
C:\Users\zqm\Documents\未命名1.cpp:115:4: error: 't' was not declared in this scope
t=(p+i);
^
C:\Users\zqm\Documents\未命名1.cpp:121:15: error: 'SavadataFunc' was not declared in this scope
SavadataFunc();
^
C:\Users\zqm\Documents\未命名1.cpp: In function 'void QuerydataFunc()':
C:\Users\zqm\Documents\未命名1.cpp:126:2: error: 'SD' was not declared in this scope
SD sd;
^
C:\Users\zqm\Documents\未命名1.cpp:141:5: error: expected ';' before 'scanf'
scanf("%",sd.number);
^
C:\Users\zqm\Documents\未命名1.cpp:144:10: error: 'p' was not declared in this scope
if((p+i)-number=sd.number)break;
^
C:\Users\zqm\Documents\未命名1.cpp:144:15: error: 'number' was not declared in this scope
if((p+i)-number=sd.number)break;
^
C:\Users\zqm\Documents\未命名1.cpp:144:22: error: 'sd' was not declared in this scope
if((p+i)-number=sd.number)break;
^
C:\Users\zqm\Documents\未命名1.cpp:145:61: error: 'p' was not declared in this scope
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:145:64: error: expression cannot be used as a function
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:145:66: error: 'nnumber' was not declared in this scope
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:145:80: error: 'name' was not declared in this scope
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:145:91: error: 'sf' was not declared in this scope
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:148:66: error: 'sa' was not declared in this scope
printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
^
C:\Users\zqm\Documents\未命名1.cpp:148:78: error: 'da' was not declared in this scope
printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
^
C:\Users\zqm\Documents\未命名1.cpp:148:90: error: 'df' was not declared in this scope
printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
^
C:\Users\zqm\Documents\未命名1.cpp:155:16: error: 'sd' was not declared in this scope
scanf("%s",sd.name);
^
C:\Users\zqm\Documents\未命名1.cpp:158:17: error: 'p' was not declared in this scope
if(strcmp((p+i)-name=sd.name)==0)break;
^
C:\Users\zqm\Documents\未命名1.cpp:158:22: error: 'name' was not declared in this scope
if(strcmp((p+i)-name=sd.name)==0)break;
^
C:\Users\zqm\Documents\未命名1.cpp:159:61: error: 'p' was not declared in this scope
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:159:64: error: expression cannot be used as a function
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:159:66: error: 'nnumber' was not declared in this scope
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:159:80: error: 'name' was not declared in this scope
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:159:91: error: 'sf' was not declared in this scope
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:162:66: error: 'sa' was not declared in this scope
printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
^
C:\Users\zqm\Documents\未命名1.cpp:162:78: error: 'da' was not declared in this scope
printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
^
C:\Users\zqm\Documents\未命名1.cpp:162:90: error: 'df' was not declared in this scope
printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
^
C:\Users\zqm\Documents\未命名1.cpp:169:16: error: request for member 'sd' in '"%s"', which is of non-class type 'const char [3]'
scanf("%s".sd.time);
^
C:\Users\zqm\Documents\未命名1.cpp:172:17: error: 'p' was not declared in this scope
if(strcmp((p+i)-name=sd.name)==0)break;
^
C:\Users\zqm\Documents\未命名1.cpp:172:22: error: 'name' was not declared in this scope
if(strcmp((p+i)-name=sd.name)==0)break;
^
C:\Users\zqm\Documents\未命名1.cpp:172:27: error: 'sd' was not declared in this scope
if(strcmp((p+i)-name=sd.name)==0)break;
^
C:\Users\zqm\Documents\未命名1.cpp:173:61: error: 'p' was not declared in this scope
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:173:64: error: expression cannot be used as a function
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:173:66: error: 'nnumber' was not declared in this scope
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:173:80: error: 'name' was not declared in this scope
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:173:91: error: 'sf' was not declared in this scope
printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d"(p+i)-nnumber,(p+i)-name,(p+i)-sf);
^
C:\Users\zqm\Documents\未命名1.cpp:176:66: error: 'sa' was not declared in this scope
printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
^
C:\Users\zqm\Documents\未命名1.cpp:176:78: error: 'da' was not declared in this scope
printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
^
C:\Users\zqm\Documents\未命名1.cpp:176:90: error: 'df' was not declared in this scope
printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)-sa[j],(p+i)-da[j],(p+i)-df);
^
C:\Users\zqm\Documents\未命名1.cpp: In function 'void DeleteFunc()':
C:\Users\zqm\Documents\未命名1.cpp:191:7: error: 'p' was not declared in this scope
if((p+i)-number==0)
^
C:\Users\zqm\Documents\未命名1.cpp:191:12: error: 'number' was not declared in this scope
if((p+i)-number==0)
^
C:\Users\zqm\Documents\未命名1.cpp:193:17: error: 'name' was not declared in this scope
strcpy((p+i)-name,(p+j+1)-name);
^
C:\Users\zqm\Documents\未命名1.cpp:194:10: error: 'sf' was not declared in this scope
(p+i)-sf=(p+i+1)-sf;
^
C:\Users\zqm\Documents\未命名1.cpp:199:7: error: 'p' was not declared in this scope
(p+i)-sd[j]=(p+i+1)-sd[j+1];
^
C:\Users\zqm\Documents\未命名1.cpp:199:12: error: 'sd' was not declared in this scope
(p+i)-sd[j]=(p+i+1)-sd[j+1];
^
C:\Users\zqm\Documents\未命名1.cpp:200:12: error: 'df' was not declared in this scope
(p+i)-df=(p+i+1)-df[j+1];
^
C:\Users\zqm\Documents\未命名1.cpp:201:19: error: 'time' was not declared in this scope
strcpy((p+i)-time[j],(p+i+1)-time[j+1]);
^
C:\Users\zqm\Documents\未命名1.cpp:204:18: error: 'SavadataFunc' was not declared in this scope
SavadataFunc();
^
编译结果...
--------
- 错误: 70
- 警告: 0
- 编译时间: 2.22s