| ÍøÕ¾Ê×Ò³ | Òµ½çÐÂÎÅ | С×é | Íþ¿Í | È˲Š| ÏÂÔØƵµÀ | ²©¿Í | ´úÂëÌù | ÔÚÏß±à³Ì | ±à³ÌÂÛ̳
»¶Ó­¼ÓÈëÎÒÃÇ£¬Ò»Í¬Çд輼Êõ
Óû§Ãû£º   
 
ÃÜ¡¡Â룺  
¹²ÓÐ 398 È˹Ø×¢¹ý±¾Ìû
±êÌ⣺vc++6.0ͨѶ¼ϵͳ ÔËÐÐʱÎ޹ʽáÊø£¡£¡
Ö»¿´Â¥Ö÷ ¼ÓÈëÊÕ²Ø
zrl873936645
Rank: 1
µÈ¡¡¼¶£ºÐÂÊÖÉÏ·
Ìû¡¡×Ó£º6
ר¼Ò·Ö£º4
×¢¡¡²á£º2013-6-19
ÊÕ²Ø
 ÎÊÌâµãÊý£º0 »Ø¸´´ÎÊý£º0 
vc++6.0ͨѶ¼ϵͳ ÔËÐÐʱÎ޹ʽáÊø£¡£¡
³ÌÐò´úÂ룺
/*ͨѶ²¾*/
#include<stdio.h>
struct person
{
    char name[8];
    char num[10];
    char ege[5];
    char sex[5];
    char tel[15];       
    char addr[50];
};
char filename[20];
FILE *fp;
void creat();
void output();
void search();
void append();
void modify();
void delete();
void main()
{
    int m;

    creat(); 
    while(1)
    {
        printf("\n\nÌí¼Ó£¬Çë°´1");
         printf("\n²éÕÒ£¬Çë°´2");
        printf("\nÐ޸ģ¬Çë°´3");
        printf("\nɾ³ý£¬Çë°´4");
        printf("\nÊä³ö£¬Çë°´5");
        printf("\nÍ˳ö£¬Çë°´0\n");
        scanf("%d",&m);
        if(m>=0&&m<=5)
        {
            switch(m)
            {
            case 1: append();
                    break;
            case 2: search();
                    break;
            case 3: modify();
                    break;
            case 4: delete();
                    break;
            case 5: output();
                    break;
            case 0: exit();
            }
         printf("\n\n²Ù×÷Íê±Ï£¬ÇëÔÙ´ÎÑ¡Ôñ£¡");
         }
        else
            printf("\n\nÑ¡Ôñ´íÎó£¬ÇëÔÙ´ÎÑ¡Ôñ£¡");
    }
}

void creat()
{
    struct person one;
    long s1;
    printf("\nÇëÊäÈëͨѶ²¾Ãû£º");
    scanf("%s",filename);
    if((fp=fopen(filename,"w"))==NULL)
    {
        printf("\n²»Äܽ¨Á¢Í¨Ñ¶²¾£¡");
        exit();
    }
    fprintf(fp,"%-10s%-10s%-6s%-6s%-20s%-50s\n","ÐÕÃû","ѧºÅ","ÄêÁä","ÐÔ±ð","µç»°ºÅÂë","סַ");
    printf("\nÇëÊäÈëÐÕÃû¡¢Ñ§ºÅ¡¢ÄêÁä¡¢ÐԱ𡢵绰ºÅÂ뼰סַ£¨ÒÔ0½áÊø£©\n");       
    scanf("%s",one.name);
    while(strcmp(one.name,"0"))
    {
        scanf("%s%s%s%s%s",one.num,one.ege,one.sex,one.tel,one.addr);                       
        fprintf(fp,"%-10s%-10s%-6s%-6s%-20s%-50s\n",one.name,one.num,one.ege,one.sex,one.tel,one.addr);
        scanf("%s",one.name);
    }
    fclose(fp);
    system("pause");
}
void output()
{
    struct person one;
    if((fp=fopen(filename,"r"))==NULL)
    {
        printf("\n²»ÄÜ´ò¿ªÍ¨Ñ¶²¾£¡");
        exit();
    }
    printf("\n\n%20s\n","ͨ Ѷ ²¾");
    while(!feof(fp))
    {
        fscanf(fp,"%s%s%s%s%s%s\n",one.name,one.num,one.ege,one.sex,one.tel,one.addr);   
        printf("%-10s%-10s%-6s%-6s%-20s%-50s",one.name,one.num,one.ege,one.sex,one.tel,one.addr);
    }
    fclose(fp);
}
void append()
{
    struct person one;
    if((fp=fopen(filename,"a"))==NULL)
    {
        printf("\n²»ÄÜ´ò¿ªÍ¨Ñ¶²¾£¡");
        exit();
    }
    printf("\nÇëÊäÈëÌí¼ÓµÄÐÕÃû¡¢Ñ§ºÅ¡¢ÄêÁä¡¢ÐԱ𡢵绰ºÅÂ뼰סַ\n");       
    scanf("%s%s%s%s%s%s",one.name,one.num,one.ege,one.sex,one.tel,one.addr);       
    fprintf(fp,"%-10s%-10s%-6s%-6s%-20s%-50s\n",one.name,one.num,one.ege,one.sex,one.tel,one.addr);
    fclose(fp);
}
void search()
{
    int k=0;
    char namekey[8];
    struct person one;
    printf("\nÇëÊäÈëÐÕÃû:");
    scanf("%s",namekey);
    if((fp=fopen(filename,"rb"))==NULL)
    {
        printf("\n²»ÄÜ´ò¿ªÍ¨Ñ¶²¾£¡");
        exit();
    }
    while(!feof(fp))
    {
        fscanf(fp,"%s%s%s%s%s%s\n",one.name,one.num,one.ege,one.sex,one.tel,one.addr);
        if(!strcmp(namekey,one.name))
        {
            printf("\n\nÒѲ鵽£¬¼Ç¼Ϊ£º");
            printf("\n%-10s%-10s%-6s%-6s%-20s%-50s",one.name,one.num,one.ege,one.sex,one.tel,one.addr);
            k=1;
        }
    }
    if(!k)
        printf("\n\n¶Ô²»Æð£¬Í¨Ñ¶²¾ÖÐûÓдËÈ˵ļǼ¡£");
    fclose(fp);
}
void modify()
{
    int m,k=0;
    long offset;
    char namekey[8];
    struct person one;
    printf("\nÇëÊäÈëÐÕÃû:");
    scanf("%s",namekey);
    if((fp=fopen(filename,"r+"))==NULL)
    {
        printf("\n²»ÄÜ´ò¿ªÍ¨Ñ¶²¾£¡");
        exit();
    }
    while(!feof(fp))
    {
        offset=ftell(fp);
        fscanf(fp,"%s%s%s%s%s%s\n",one.name,one.num,one.ege,one.sex,one.tel,one.addr);
        if(!strcmp(namekey,one.name))
        {
            k=1;
            break;
        }
    }
    if(k)
    {
        printf("\nÒѲ鵽£¬¼Ç¼Ϊ£º");
        printf("\n%-10s%-10s%-6s%-6s%-20s%-50s",one.name,one.num,one.ege,one.sex,one.tel,one.addr);
        printf("\nÇëÊäÈëÐÂÐÕÃû¡¢Ñ§ºÅ¡¢ÄêÁä¡¢ÐԱ𡢵绰ºÅÂ뼰סַ£º");
        scanf("%s%s%s%s%s%s",one.name,one.num,one.ege,one.sex,one.tel,one.addr);
        fseek(fp,offset,SEEK_SET);
        printf("%ld",ftell(fp));
        fprintf(fp,"%-10s%-10s%-6s%-6s%-20s%-50s\n",one.name,one.num,one.ege,one.sex,one.tel,one.addr);
    }
    else
        printf("\n¶Ô²»Æð£¬Í¨Ñ¶²¾ÖÐûÓдËÈ˵ļǼ¡£");
    fclose(fp);
}
void delete()
{
    int m,k=0,flag;
    long offset1,offset2;
    char namekey[8], valid[4];
    struct person one;
    printf("\nÇëÊäÈëÐÕÃû:");
    scanf("%s",namekey);
    if((fp=fopen(filename,"r+"))==NULL)
    {
        printf("\n²»ÄÜ´ò¿ªÍ¨Ñ¶²¾£¡");
        exit();
    }
    while(!feof(fp))
    {
        offset1=ftell(fp);
        fscanf(fp,"%s%s%s%s%s%s\n",one.name,one.num,one.ege,one.sex,one.tel,one.addr);
        if(!strcmp(namekey,one.name))
        { 
            k=1;
            break;
        }
    }
    if(k)
    {
        printf("\nÒѲ鵽£¬¼Ç¼Ϊ");
        printf("\n%-10s%-10s%-6s%-6s%-20s%-50s",one.name,one.num,one.ege,one.sex,one.tel,one.addr);
        printf("\nȷʵҪɾ³ý,°´1£»²»É¾³ý£¬°´0£º");
        scanf("%d",&m);
        if(m)
        { 
            fseek(fp,offset1,SEEK_SET);
            fprintf(fp,"%-10s%-10s%-6s%-6s%-20s%-50s\n","","","","","","");
        }
    }
    else
        printf("\n¶Ô²»Æð£¬Í¨Ñ¶²¾ÖÐûÓдËÈ˵ļǼ¡£");
    fclose(fp);
}

±àÒëûÎÊÌâ  ÔËÐÐҲûÎÊÌâ   ¾ÍÊÇÔÚÊäÈëµÚ¶þ¸öÁªÏµÈËʱ  ´°¿ÚÎÞ¹ÊÏûʧ  Çó¾È£¿£¿£¿
ËÑË÷¸ü¶àÏà¹ØÖ÷ÌâµÄÌû×Ó: person¡¡Í¨Ñ¶Â¼¡¡color¡¡
2013-06-19 20:52
¿ìËٻظ´£ºvc++6.0ͨѶ¼ϵͳ ÔËÐÐʱÎ޹ʽáÊø£¡£¡
Êý¾Ý¼ÓÔØÖÐ...
 
¡¡¡¡¡¡



¹ØÓÚÎÒÃÇ | ¹ã¸æºÏ×÷ | ±à³ÌÖйú | Çå³ýCookies | TOP | ÊÖ»ú°æ

±à³ÌÖйú °æȨËùÓУ¬²¢±£ÁôËùÓÐȨÀû¡£
Powered by Discuz, Processed in 0.019053 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved