| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 562 人关注过本帖
标题:这出什么错了,请各位高手看看!
只看楼主 加入收藏
梦ambious
Rank: 2
等 级:论坛游民
帖 子:27
专家分:71
注 册:2011-11-25
结帖率:75%
收藏
已结贴  问题点数:20 回复次数:2 
这出什么错了,请各位高手看看!
#include<iostream>
#include<windows.h>
#include<cstdlib>
#include<conio.h>
#include<string>
using namespace std;
typedef struct people
{
    char id[10];
    int number;//人员号
    char name[10];//人员姓名
    char sex[10];//girl为女,boy为男
    char birthday[12];
    char telephone[13];
    char address[40];
} people;
void chakan(struct people p[]);  /*查看所有人员的信息*/
void chaxun(struct people p[]);  /*查询单个人员的信息*/
void shanchu(struct people p[]);  /*删除某个人员的信息*/
void tianjia(struct people p[]);  /*添加一个人员的信息*/
void main()
{
    struct people p[100];
    int choice;
    do{
        system("cloor 2e");
        system("cls");
        cout<<"\n\t\t\通 讯 录 管 理 系 统";
        cout<<"\n\t\t\t\t\t\t\长安大学";
        cout<<"\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
        cout<<"\n\t*功能菜单*:\n";
        cout<<"\n\t\t------------------------------\n";
        cout<<"\t\t2:查询");
        cout<<"\n\t\t------------------------------\n";
        cout<<"\t\t3:删除");
        cout<<"\n\t\t------------------------------\n";
        cout<<"\t\t4:添加");
        cout<<"\n\t\t------------------------------\n";
        cout<<"请选择功能---------------------------\n";
        cin>>choice;
        switch(choice)
        {
        case 0:     system("color 3e");
            system("cls");
            cout<<("\n\n\n\n\n\n\n\t\t\t\退出系统\n");
            int i;
            for (i=5;i>=0;i--)
            {
                sleep(1000);
                system("cls");
                system("color 4e");
                cout<<("\n\n\n\n\n\n\n\t\t\t\请稍等,还剩下%d退出系统\n\n\n,i");
                system("color 6e");
                system("cls");
                cout<<("\n\n\n\n\n\t*您已成功退出系   统!\n\t@谢谢使用!\n");
                exit(0);
                break;
        case l:
            system("color 2f");
            system("cls");
            cout<<"查看所有人员的信息:\n";
            chakan(p);
            break;
        case 2:
            system("color 5e");
            system("cls");
            cout<<"查询但个人员的信息:\n";
            chaxun(p);
            break;
        case 3:
            system("color 8e");
            system("cls");
            cout<<"删除一个人员\n";
            shanchu(p);
            getch();
            break;
        case 4:
            system("color 9f");
            system("cls");
            cout<<"添加一个人员\n";
            tianjia(P);
            break;
        default:
            system("color 9e");
            system("cls");
            cout<<"\n\n\n\t\t\t\请正确选择!\n\n";
            system("pause");
            }
        }while(l);
        //查看函数
        
        void chakan(struct people p[])
        {
            FILE*fp;
            int i=0,n=0;
            if((fp=fopen("e: \\personInfo.txt","r"))==NULL)
            {
                cout<<"不能打开文件"<<endl;
                exit(0);
            }
            while(!feof(fp)){
                fin>><<fp<<p[i].number<<p[i]<<name<<p[i]<<sex<<p[i]<<birthday<<p[i]
                    
                    <<telephone<<p[i]<<address);
                i++;
            }
            n=i;
            fclose(fp);
            for(i=1;i<n;i++)
            {
                cout<<"输出该人员的信息"<<endl;
                cout<<"人员号"<<p[i].number<<endl;
                cout<<"姓名:"<<p[i].name<<endl;
                cout<<"性别:"<<p[i].sex<<endl;
                cout<<"生日:"<<p[i].birthday<<endl;
                cout<<"电话:"<<p[i].telephone<<endl;
                cout<<"地址:"<<p[i].address<<endl;
                cout<<endl;
            }
            getch();
        }
        楚盼  15:10:17
            //查询函数
            void chaxun(struct people p[])
        {
            FILE*fp;
            int i=0,j=0,a,flag=0,n=0;
            if((fp=fopen("e: \\personInfo.txt","r"))==NULL)
            {
                cout<<"不能打开文件"<<endl;
                exit(0);
            }
            while(!feof(fp)){
                fin>><<fp<<p[i].number<<p[i]<<name<<p[i]<<sex<<p[i]<<birthday<<p[i]
                    
                    <<telephone<<p[i]<<address);
                i++;
            }
            n=i;
            cout<<"请输入查询人员号:"<<endl;
            cin>>a;
            for(i=1;i<n;i++)
            {
                if(a==p[i].number)
                    cout<<"输出该人员的信息"<<endl;
                cout<<"人员号"<<p[i].number<<endl;
                cout<<"姓名:"<<p[i].name<<endl;
                cout<<"性别:"<<p[i].sex<<endl;
                cout<<"生日:"<<p[i].birthday<<endl;
                cout<<"电话:"<<p[i].telephone<<endl;
                cout<<"地址:"<<p[i].address<<endl;
                flag=1;
                break;
            }
        }
        if(flag!=1)
            cout<<"对不起,无此人员号!"<<endl;
        fclose(fp);
        getch();
}
/添加函数/
void tianjia(struct people p[])
{
abcd:FILE*fp;
     people a,h;
     int count=0,m=0;
     int i=0,j,b,c=0;
     if((fp=fopen("e: \\personInfo.txt","r"))==NULL)
     {
         cout<<"can not open the file!"<<endl;
         fp=fopen("e: \\personInfo.txt","w");
         cout<<"请输入人员号:"<<endl;
         cin>>a.number;
     }
     else{
         while(!feof(fp)){
             fin>><<fp<<p[i].number<<p[i]<<name<<p[i]<<sex<<p[i]<<birthday<<p
                 
                 [i]<<telephone<<p[i]<<address);
             i++;
         }//从磁盘读人员信息
         fclose(fp);
         do{
             b=0
                 c=0;
             cout<<"请输入人员号:"<<endl;
             cin>>a.number;
             count=i;
             for(i=0;i<count;i++){
                 if(a.number==p[i].number){
                     c=-1;
                     break;}
             }
             if(c==-1){
                 cout<<"人员号重复,请重新输入!"<<endl;
                 goto abcd;}
             else
                 break;
         }while(b);//判断人员号是否重复
     }
     cout<<"请输入姓名"<<endl;
     cin>>a.name;
     cout<<"请输入性别"<<endl;
     cin>>a.sex;
     cout<<"请输入生日"<<endl;
     cin>>a.birthday;
     cout<<"请输入电话"<<endl;
     cin>>a.telephone;
     cout<<"请输入地址"<<endl;
     cin>>a.address;
     p[count]=a;
     count++;
         for(i=1;i<count;i++){
             for(j=0;j<(count-1);j++){
                 if(p[j].number>p[j+1].number){
                     h=p[j];
                     p[j]=p[j+1];
                     p[j+1]=h;
                 }
             }
         }//排序
         fp=fopen("e: \\personInfo.txt","w");
         for(i=0;i<count;i++)
         {
             if(i==0)
                 fout<<p[i].number<<p[i].name<<p[i].sex<<p[i].birthday<<p
                 
                 [i].telephone<<p[i].address<<endl;
             else
                 fout<<\n<<p[i].number<<p[i].name<<p[i].sex<<p
                 
                 [i].birthday<<p[i].telephone<<p[i].address<<endl;
         }//重新写入磁盘
         fclose(fp);
         getch();
}
//删除函数
void tianjia(struct people p[])
{
    FILE*fp;
    int n=0;
    if((fp=fopen("e: \\personInfo.txt","r"))==NULL)
    {
        cout<<"不能打开文件"<<endl;
        exit(0);
    }
    int i=1,a,b=-1;
        cout<<""<<endl;
    cin>>a;
    while(!feof(fp)){
        fin>><<fp<<p[i].number<<p[i]<<name<<p[i]<<sex<<p[i]<<birthday<<p[i]
            
            <<telephone<<p[i]<<address);
        i++;
    }
    fclose(fp);
    n=i;
    if((fp=fopen("e: \\personInfo.txt","r"))==NULL)
    {
        cout<<"不能打开文件"<<endl;
        exit(0);
    }
    for(i=1;i<count;i++)
    {
        if(p[i].number==a)
        {
            b=0;
        }
        else{
            if(i==0)
                fout<<p[i].number<<p[i].name<<p[i].sex<<p[i].birthday<<p
               
                [i].telephone<<p[i].address<<endl;
            else
                fout<<\n<<p[i].number<<p[i].name<<p[i].sex<<p
               
                [i].birthday<<p[i].telephone<<p[i].address<<endl;
        }
    }
    fclose(fp);
    if(b!=0)
        cout<<"对不起,你要删除的人员号不存在!"<<endl;
    else
        cout<<"删除成功!"<<endl;
}

搜索更多相关主题的帖子: 信息 姓名 telephone address include 
2011-12-20 15:14
梦ambious
Rank: 2
等 级:论坛游民
帖 子:27
专家分:71
注 册:2011-11-25
收藏
得分:0 
我改正了一些,可还是有问题,求高手给看一看
//通讯录
#include<stdio.h>
#include<windows.h>
#include<stdlib.h>
#include<conio.h>
#include<string.h>
typedef struct people{
    char id[10];
    int number;//人员号
    char name[10];//人员姓名
    char sex[10];//girl为女,boy为男
    char birthday[12];
    char telephone[13];
    char address[40];
   
 } people;
void chakan(struct people p[]);  /*查看所有人员的信息*/
void chaxun(struct people p[]);  /*查询单个人员的信息*/
void shanchu(struct people p[]);  /*删除某个人员的信息*/
void tianjia(struct people p[]);  /*添加一个人员的信息*/
void main()
{
    struct people p[1000];
    int choice;
    do{
        system("cloor 2e");
        system("cls");
        printf("%d\n\t\t通 讯 录 管 理 系 统");
        printf("%d\n\t\t\t\t\t\t长安大学");
        printf("%d\n");
        printf("%d\n\t*功能菜单*:\n");
        printf("%d\n\t\t------------------------------\n");
        printf("%d\t\t1查看:\n");
        printf("%d\n\t\t------------------------------\n");
        printf("%d\t\t2:查询");
        printf("%d\n\t\t------------------------------\n");
        printf("%d\t\t3:删除");
        printf("%d\n\t\t------------------------------\n");
        printf("%d\t\t4:添加");
        printf("%d\n\t\t------------------------------\n");
        {
            switch(choice){
            case 0:     system("color 3e");
            system("cls");
            printf("%d\n\n\n\n\n\n\n\t\t\t退出系统\n");
            int i;
            for (i=5;i>=0;i--)
            {
                Sleep(1000);
                system("cls");
                system("color 4e");
                printf("%d\n\n\n\n\n\n\n\t\t\t请稍等,还剩下%d退出系统\n\n\n,i");
                system("color 6e");
                system("cls");
                printf("%d\n\n\n\n\n\t*您已成功退出系统!\n\t@谢谢使用!\n");
                exit(0);
                break;
        case 1:
            system("color 2f");
            system("cls");
            printf("查看所有人员的信息:\n");
            chakan(p);
            break;
        case 2:
            system("color 5e");
            system("cls");
            printf("%d查询但个人员的信息:\n");
            chaxun(p);
            break;
        case 3:
            system("color 8e");
            system("cls");
            printf("%d删除一个人员\n");
            shanchu(p);
            getch();
            break;
        case 4:
            system("color 9f");
            system("cls");
            printf("%d添加一个人员\n");
            tianjia(p);
            break;
        default:
            system("color 9e");
            system("cls");
            printf("%d\n\n\n\t\t\t请正确选择!\n\n");
            system("pause");
            }
        }while(1);
//查看//
void chakan(struct people p[]){
    FILE*fp;
    int i=0,n=0;
    if((fp=fopen("e:\\personInfo.txt","r"))==NULL)
     {
        printf("%d不能打开文件");
        exit(0);
    }
    while(!feof(fp)){
        fscanf(fp,"%d%s%s%s%s%s",&p[i].number,p[i].name,p[i].sex,p[i].birthday,p[i].telephone,p[i].address);
        i++;
    }
    n=i;
    fclose(fp);
    for(i=1;i<n;i++)
    {
            printf("%d人员号:%d\t",p[i].number);
            printf("%d姓名:%s\t",p[i].name);
            printf("%d性别:%s\t",p[i].sex);
            printf("%d生日:%s\t",p[i].birthday);
            printf("%d电话:%s\t",p[i].telephone);
            printf("%d地址:%s\t",p[i].address);
            printf("%d****************************\n");
    }
         getch();
}
//查询函数
void chaxun(struct people p[])
{
    FILE*fp;
    int i=0,j=0,a,flag=0,n=0;
    if((fp=fopen("e:\\personInfo.txt","r"))==NULL)
     {
        printf("不能打开文件");
        exit(0);
    }
    while(!feof(fp)){
        fscanf(fp,"%d%s%s%s%s%s",&p[i].number,p[i].name,p[i].sex,p[i].birthday,p[i].telephone,p[i].address);
        i++;
    }
    n=i;
    printf("请输入查询人员号:");
    scanf("%d",&a);
    for(i=1;i<n;i++)
    {
        int flag=0;
        if(a==p[i].number)
            printf("%d输出该人员的信息:\n");
            printf("%d\t人员号:%d\n",p[i].number);
            printf("%d\t姓名:%s\n",p[i].name);
            printf("%d\t性别:%s\n",p[i].sex);
            printf("%d\t生日:%s\n",p[i].birthday);
            printf("%d\t电话:%s\n",p[i].telephone);
            printf("%d\t地址:%s\n",p[i].address);
        flag=1;
        break;
    }
     if(flag!=1)
                 printf("%d对不起,无此人员号!");
         fclose(fp);
         getch();
}
/*添加函数*/
void tianjia(struct people p[])
{
abcd:FILE*fp;
     people a,h;
     int count=0,m=0;
     int i=0,j,b,c=0;
     if((fp=fopen("e:\\personInfo.txt","r"))==NULL){
         printf("can not open the file!"<<endl;
         fp=fopen("e:\\personInfo.txt","w");
         printf("%d请输入人员号:");
         scanf"%d",&a.number);}
     else{
         while(!feof(fp))
         {
             fscanf(fp,"%d%s%s%s%s%s",&p[i].number,p[i].name,p[i].sex,p[i].birthday,p[i].telephone,p[i].address);
             i++;
         }
         //从磁盘读人员信息
         fclose(fp);
         do{
             b=0
                 c=0;
             printf("%d请输入人员号:");
             cin>>a.number;
             count=i;
             for(i=0;i<count;i++){
                 if(a.number==p[i].number){
                     c=-1;
                     break;}
             }
             if(c==-1){
             printf("%d人员号重复,请重新输入!\n");
             goto abcd;}
             else
                 break;
         }while(b);//判断人员号是否重复
     }
     printf("请输入姓名");
     scanf("%d",&a.name);
     printf("请输入性别");
     scanf("%d",&a.sex);
     printf("请输入生日");
     scanf("%d",&a.birthday);
     printf("请输入电话");
     scanf("%d",&a.telephone);
     printf("请输入地址");
     scanf("%d",&a.address);
     p[count]=a;
     count++;
         for(i=1;i<count;i++){
             for(j=0;j<(count-1);j++){
                 if(p[j].number>p[j+1].number){
         h=p[j];
         p[j]=p[j+1];
         p[j+1]=h;
                 }
             }
         }//排序
         fp=fopen("e:\\personInfo.txt","w");
         for(i=0;i<count;i++)
         {
             if(i==0)
                 fprintf(fp,"%d%s%s%s%s%s",p[i].number,p[i].name,p[i].sex,p[i].birthday,p[i].telephone,p[i].address);
             else
                 fprintf(fp,"\n%d%s%s%s%s%s",p[i].number,p[i].name,p[i].sex,p[i].birthday,p[i].telephone,p[i].address);
         }//重新写入磁盘
         fclose(fp);
         getch();
}
//删除函数
void tianjia(struct people p[])
{
    FILE*fp;
    int n=0;
    if((fp=fopen("e:\\personInfo.txt","r"))==NULL)
     {
        printf("不能打开文件");
        exit(0);
    }
    int i=1,a,b=-1;
        printf("请输入要删除的人员号:\n");
    scanf("%d",&a);
    while(!feof(fp)){
         fscanf(fp,"%d%s%s%s%s%s",&p[i].number,p[i].name,p[i].sex,p[i].birthday,p[i].telephone,p[i].address);
        i++;
    }
    fclose(fp);
    n=i;
    if((fp=fopen("e:\\personInfo.txt","r"))==NULL)
     {
        printf("不能打开文件");
        exit(0);
    }
    for(i=1;i<count;i++)
    {
        if(p[i].number==a)
        {
            b=0;
        }
        else{
            if(i==0)
                fprintf(fp,"%d%s%s%s%s%s",p[i].number,p[i].name,p[i].sex,p[i].birthday,p[i].telephone,p[i].address);
            else
                fprintf(fp,"\n%d%s%s%s%s%s",p[i].number,p[i].name,p[i].sex,p[i].birthday,p[i].telephone,p[i].address);
        }
    }
    fclose(fp);
    if(b!=0)
        printf("对不起,你要删除的人员号不存在!");
    else
        printf("\n\n\n\\t\t\t删除成功!");}
2011-12-21 11:04
BianChengNan
Rank: 8Rank: 8
等 级:贵宾
威 望:13
帖 子:302
专家分:972
注 册:2011-11-30
收藏
得分:20 
以下是引用梦ambious在2011-12-21 11:04:19的发言:

我改正了一些,可还是有问题,求高手给看一看
//通讯录
#include
#include
#include
#include
#include
typedef struct people{
    char id[10];
    int number;//人员号
    char name[10];//人员姓名
    char sex[10];//girl为女,boy为男
    char birthday[12];
    char telephone[13];
    char address[40];
   
 } people;
void chakan(struct people p[]);  /*查看所有人员的信息*/
void chaxun(struct people p[]);  /*查询单个人员的信息*/
void shanchu(struct people p[]);  /*删除某个人员的信息*/
void tianjia(struct people p[]);  /*添加一个人员的信息*/
void main()
{
    struct people p[1000];
    int choice;
    do{
        system("cloor 2e");
        system("cls");
        printf("%d\n\t\t通 讯 录 管 理 系 统");
        printf("%d\n\t\t\t\t\t\t长安大学");
        printf("%d\n");
        printf("%d\n\t*功能菜单*:\n");
        printf("%d\n\t\t------------------------------\n");
        printf("%d\t\t1查看:\n");
        printf("%d\n\t\t------------------------------\n");
        printf("%d\t\t2:查询");
        printf("%d\n\t\t------------------------------\n");
        printf("%d\t\t3:删除");
        printf("%d\n\t\t------------------------------\n");
        printf("%d\t\t4:添加");
        printf("%d\n\t\t------------------------------\n");
        {
            switch(choice){
            case 0:     system("color 3e");
            system("cls");
            printf("%d\n\n\n\n\n\n\n\t\t\t退出系统\n");
            int i;
            for (i=5;i>=0;i--)
            {
                Sleep(1000);
                system("cls");
                system("color 4e");
                printf("%d\n\n\n\n\n\n\n\t\t\t请稍等,还剩下%d退出系统\n\n\n,i");
                system("color 6e");
                system("cls");
                printf("%d\n\n\n\n\n\t*您已成功退出系统!\n\t@谢谢使用!\n");
                exit(0);
                break;
        case 1:
            system("color 2f");
            system("cls");
            printf("查看所有人员的信息:\n");
            chakan(p);
            break;
        case 2:
            system("color 5e");
            system("cls");
            printf("%d查询但个人员的信息:\n");
            chaxun(p);
            break;
        case 3:
            system("color 8e");
            system("cls");
            printf("%d删除一个人员\n");
            shanchu(p);
            getch();
            break;
        case 4:
            system("color 9f");
            system("cls");
            printf("%d添加一个人员\n");
            tianjia(p);
            break;
        default:
            system("color 9e");
            system("cls");
            printf("%d\n\n\n\t\t\t请正确选择!\n\n");
            system("pause");
            }
        }while(1);
//查看//
void chakan(struct people p[]){
    FILE*fp;
    int i=0,n=0;
    if((fp=fopen("e:\\personInfo.txt","r"))==NULL)
     {
        printf("%d不能打开文件");
        exit(0);
    }
    while(!feof(fp)){
        fscanf(fp,"%d%s%s%s%s%s",&p.number,p.name,p.sex,p.birthday,p.telephone,p.address);
        i++;
    }
    n=i;
    fclose(fp);
    for(i=1;i
什么错误请说一下吧,要不我们这种没环境运行代码的选手很悲剧啊

我的群:149544757 C/C++/Assembly 喜欢交流的朋友进,进群请写消息
2011-12-21 16:22
快速回复:这出什么错了,请各位高手看看!
数据加载中...
 
   



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

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