| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2429 人关注过本帖
标题:小区水电管理系统,有很多错误,求指点
取消只看楼主 加入收藏
zzqm
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2017-5-6
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:2 
小区水电管理系统,有很多错误,求指点
#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

搜索更多相关主题的帖子: 管理系统 include double number 门牌号 
2017-05-06 19:46
zzqm
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2017-5-6
收藏
得分:0 
是c
2017-05-06 20:23
zzqm
Rank: 1
等 级:新手上路
帖 子:8
专家分:0
注 册:2017-5-6
收藏
得分:0 
新改的,还有几个错误
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 100
#define w 1.5                    // 水1.5元/吨
#define e 0.5                    // 电0.5元/

typedef struct Residentinf
{
    int number;                  // 住户门牌号
    char name[20];               // 户主姓名
    float *wanum,*elnum;       // 用水(吨)、电(度)表示数
    float *amoney,*emoney;      // 总共的水电费用,每月的水电费用   
    char *time;                 // 收费时间
}Re[N];

int num;                         // 数据个数
Residentinf *p;                 // 指向结构体的指针

void display();
void ScandataFunc();
void CaldataFunc();
void SavedataFunc();
void AdddataFunc();
void SortdataFunc();
void QuerydataFunc();
void StatisdataFunc();
void ModifydataFunc();
void DeletedataFunc();


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:
  ModifydataFunc(); break;     //修改
 case 7:
  exit(0);                    //退出
 }
}

void display()
{
  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 ScandataFunc()
{
    int i,j;
    FILE *fp;
    fp=fopen("Data.txt","r");
    for(i=0;i<N;i++)
    {
        fscanf(fp,"%d%s%d",&(p+i)->number,(p+i)->name,&(p+i)->amoney);
        for(j=0;j<100;j++)
            fscanf(fp,"%d%d%d%s",&(p+i)->wanum,&(p+i)->elnum,&(p+i)->emoney,(p+i)->time);
    }
    fclose(fp);
}

void CaldataFunc()
{
    int i,j;
    FILE *fp;
    fp=fopen("Data.txt","w");
    for(i=0;i<N;i++)
        for(j=1;j<100;j++)
        {
            (p+i)->emoney[j]=((p+i)->wanum[j]-(p+i)->wanum[j-1])*w+((p+i)->elnum[j]-(p+i)->elnum[j-i])*e;
            (p+i)->amoney=0;
            (p+i)->amoney=(p+i)->emoney;
        }
    SavedataFunc();
}

void SavedataFunc()
{
    FILE*fp;
    fp=fopen("Data.txt","w");
    int i,j;
    for(i=0;i<N;i++)
    {
        fprintf(fp,"%d %s %d",(p+i)->number,(p+i)->name,(p+i)->amoney);
        for(j=0;j<100;j++)
            fprintf(fp,"%d %d %d %s",(p+i)->wanum,(p+i)->elnum,(p+i)->emoney,(p+i)->time);
    }
    fclose(fp);
}
   
void AdddataFunc()
{

    int n,i,j;
    re;
    printf("请输入新用户信息");
    system("cls");
    for(i=0;i<N;i++)
        {
            printf("\n\t\tnumber:");
            scanf("%d",re.number);
            (p+i)->number=re.number;
            printf("\n\t\tname:");
            scanf("%s",re.name);
            strcpy((p+i)->name,re.name);
            for(j=0;j<100;j++)
            {
                printf("\n\t\twanum:");
                scanf("%d",&re.wanum[j]);
                (p+i)->wanum=re.wanum;
                printf("\n\t\telnum:");
                scanf("%d",&re.elnum[j]);
                (p+i)->elnum=re.elnum;
                printf("\n\t\t\ttime:");
                scanf("%s",re.time[j]);
                strcpy((p+i)->time,re.time);
            }
             printf("\n登记完毕!\n");break;
        }
    SavedataFunc();
}

void SortdataFunc()
{
    int i,j;
    Re[N] *temp;
    for(i=0;i<N-1;i++)
    {
        for(j=0;j<N;j++)
        if((p+i)->number<(p+j)->number)
        {
            temp=p+i;
            p+i=p+j;
            p+j=temp;
        }
    }
    SavedataFunc();
}

void QuerydataFunc()
{
    int i,n,j;
     *re;
    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("%d",re.number);
            for(i=0;i<N;i++)
                if((p+i)->number==re[i].number)break;
            printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d",(p+i)->number,(p+i)->name,(p+i)->amoney);
            for(j=0;j<100;j++)
                printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%d",(p+i)->wanum[j],(p+i)->elnum[j],(p+i)->emoney[j]);
        }break;
    case 2:
        {
            printf("姓名:\n");
            scanf("%s",re.name);
            for(i=0;i<N;i++)
                if(strcmp((p+i)->name,re[i].name)==0)break;
            printf("\n\t住户门牌号:%d\n\t户主姓名:%s\n\t总费用:%d",(p+i)->number,(p+i)->name,(p+i)->amoney);
            for(j=0;j<100;j++)
                printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%f",(p+i)->wanum[j],(p+i)->elnum[j],(p+i)->emoney[j]);
        }break;
    case 4:
        {
            printf("日期:\n");
            scanf("%s",re.time);
            for(i=0;i<N;i++)
                for(j=0;j<100;j++)
                if(strcpy((p+i)->time[j],re.time[j])==0)break;
            printf("\n\t住户门牌号:%d\n\t户主姓名:%s",(p+i)->number,(p+i)->name);
            for(j=0;j<100;j++)
                printf("\n\t月用水量:%d\n\t月用电量:%d\n\t月费用:%f",(p+i)->wanum[j],(p+i)->elnum[j],(p+i)->emoney[j]);
        }
    }
}

void DeleteFunc()
{
    int i,j,m;
    printf("删除的住户门牌号为:[ ]\b\b");
    scanf("%d",&m);
    for(i=0;i<N;i++)
        if((p+i)->number==m)
        {
            strcpy((p+i)->name,(p+j+1)->name);
            (p+i)->amoney=(p+i+1)->amoney;
            for(j=0;j<100;j++)
            {
                (p+i)->wanum[j]=(p+i+1)->wanum[j+1];
                (p+i)->elnum[j]=(p+i+1)->elnum[j+1];
                strcpy((p+i)->time[j],(p+i+1)->time(j+1));
            }
    SavedataFunc();
        }
}


编译单个文件...
--------
- 文件名: C:\Users\zqm\Documents\未命名2.22.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\未命名2.22.cpp" -o "C:\Users\zqm\Documents\未命名2.22.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\未命名2.22.cpp: In function 'void AdddataFunc()':
C:\Users\zqm\Documents\未命名2.22.cpp:119:5: error: 're' was not declared in this scope
     re;
     ^

C:\Users\zqm\Documents\未命名2.22.cpp: In function 'void SortdataFunc()':
C:\Users\zqm\Documents\未命名2.22.cpp:150:4: error: expected unqualified-id before '[' token
  Re[N] *temp;
    ^
C:\Users\zqm\Documents\未命名2.22.cpp:156:4: error: 'temp' was not declared in this scope
    temp=p+i;
    ^
C:\Users\zqm\Documents\未命名2.22.cpp:157:7: error: lvalue required as left operand of assignment
    p+i=p+j;
       ^
C:\Users\zqm\Documents\未命名2.22.cpp: In function 'void QuerydataFunc()':
C:\Users\zqm\Documents\未命名2.22.cpp:167:4: error: 're' was not declared in this scope
   *re;
    ^
C:\Users\zqm\Documents\未命名2.22.cpp: In function 'void DeleteFunc()':
C:\Users\zqm\Documents\未命名2.22.cpp:227:44: error: expression cannot be used as a function
     strcpy((p+i)->time[j],(p+i+1)->time(j+1));
                                            ^
2017-05-07 23:02
快速回复:小区水电管理系统,有很多错误,求指点
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.027026 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved