自己做的QQ像在联机一下,望高手指点

作者在 2010-06-28 18:42:45 发布以下内容
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include "windows.h"


    
void zhuce();    /*注册函数*/
void baocun();/*保存函数*/
void grzx();   /*个人中心*/
void bangzhu();    /*帮助函数*/
void denglu();/*登陆函数*/
void liaotian();/*聊天函数*/
void xieriji();    /*写日记函数*/
void kanriji();/*看日记函数*/



int uu=0,ee;/*全局变量*/



struct yonghu                                /*定义用户数组*/
{
    char nicheng[40];/*昵称*/
    long zhanghao;/*账号*/
    char mima[10];/*密码*/
    char shengri[20];/*生日*/
    char xingbie[20];/*性别*/
    char dizhi[20];/*地址*/    
}guy1[100],guy2[100];
struct yonghu GUY;



void main()                                            /*定义住函数*/
{
    system("color 2e");                            
    system("cls");
    while(1)
    {
        system("cls");
        int a;
        printf("\n\t\t\t★☆ 欢迎使用新版抠抠 ☆★\n\n\n");
        printf("\n\n\t\t\t\t1,登陆\n\n\n\t\t\t\t2,注册\t\t\n\n\n\t\t\t\t3,帮助\t\t\n\n\n\t\t\t\t4退出\n");
        printf("\n\n\t\t\t\t\t\t\t请输入:");
        scanf("%d",&a);
        switch(a)
        {
            case 1:denglu();break;/*登陆*/
            case 2:zhuce();break;/*注册*/
            case 3:bangzhu();break;/*帮助*/
            case 4:exit(0);/*退出*/
            default :printf("您输入的有误,请按任意键重新输入:");getch();
        }
    }
    return;
}





void zhuce()                                            /*注册函数*/
{
    system("color 3e");
    system("cls");
    fflush(stdin);/*清除流*/
    int hh;
    printf("\n\t\t\t\t免费申请抠抠号\n\n");
    printf("按1开始注册,按0返回");
    scanf("%d",&hh);printf("\n");
    if(hh==1)
    {
        int i;
        for(i=0;i<100;i++)
        {
            int kk;
            printf("请输入您的昵称:");
            fflush(stdin);
            gets(guy1[i].nicheng);printf("\n");
            printf("请输入账号(纯数字少于10位):");
            scanf("%ld",&guy1[i].zhanghao);printf("\n");
            printf("请输入您的密码(字母少于7位):");
            fflush(stdin);
            gets(guy1[i].mima);printf("\n");
            printf("请输入您的生日:");
            fflush(stdin);
            gets(guy1[i].shengri);printf("\n");
            printf("请输入您的性别(boy or gile):");
            fflush(stdin);
            gets(guy1[i].xingbie);printf("\n");
            printf("请输入您的地址:");
            fflush(stdin);
            gets(guy1[i].dizhi);printf("\n");
            uu+=1;/*uu是全局变量*/
            printf("按1继续注册,按0返回");
            scanf("%d",&kk);
            if(kk==0)break;
        
        }
        baocun();/*保存函数*/
        printf("请等待2秒钟……");
        Sleep(2000);
    }
    
}





void baocun()                                                /*保存函数*/
{
    FILE *file;
    if((file=fopen("xinxi.dat","wb"))==NULL)/*打开文件-只写*/
    {
        printf("对不起,您注册失败!\n");
        printf("请稍后再试,按人任意键返回:");
        getch();
    }
    else
    {
        int a;
        for(a=0;a<uu;a++)
        fwrite(&guy1[a],sizeof(GUY),1,file);/*写入文件*/
        printf("恭喜您注册成功\n");
    
    }
    fclose(file);/*关闭文件*/
}





void denglu()                                                    /*登陆函数*/
{
    system("color 7e");
    system("cls");
    while (1)/*死循环*/
    {
        char nn[20];/*定义数组保存密码*/
        long mm;/*定义长整形保存账号*/
        int yy,tt,ww;
        printf("\t\t\t登陆抠抠\n\n\n");
        FILE *qq;
        if((qq=fopen("xinxi.dat","rb"))==NULL)/*打开文件-只读*/
        {
            Sleep(3000);
            printf("对不起,登陆失败");
            printf("按任意键继续");
            getch();
            exit(1);
        }
        else
        {
            printf("系统准备就绪\n");
            printf("账号(6位纯数字):");/*输入账号*/
            scanf("%ld",&mm);
            for(tt=0;tt<uu;tt++)
                fread(&guy2[tt],sizeof(GUY),1,qq);    /*读取文件中的数据*/
            for(yy=0;yy<uu;yy++)/*验证账号*/
            {
                if(mm==guy2[yy].zhanghao)
                {
                    printf("此账号有效\n\n");
                    ee=yy;/*使yy的值赋予ee*/
                    break;
                }
                else
                {
                    if((yy+1)>=uu)
                    {
                        printf("%ld",guy2[yy].zhanghao);
                        printf("对不起,此账号无效,按任意键退出");
                        getch();
                        exit(0);
                    }
                }
            }
            fclose(qq);
        }


              /*转入对密码的验证*/

            printf("请输入您的密码:");/*输入密码*/
            fflush(stdin);
            gets(nn);
            if(strcmp(nn,guy2[ee].mima)==0)
            {
                printf("恭喜您登陆成功,请稍等正在转向个人中心¨¨");
                Sleep(4000);
                grzx();
            }
            else
            {
                printf("对不起,您输入的密码有误,按任意键返回");
                system("pause");
            }
            printf("返回主菜单请按1,继续登录请按0");
            scanf("%d",&ww);
            if(ww==0)continue;
            else
            {
                if(ww==1)break;
                else
                {
                    printf("您输入的有误,系统崩溃");
                    exit(0);
                }
            }
    }/*对while的结束括号*/    
}






void bangzhu()                                            /*帮助函数*/
{
    system("color 6e");
    system("cls");
    printf("\n\t\t\t★欢迎使用抠抠帮助☆");
    printf("\n\n\n");
    printf("\t1,本系统可以实现抠抠登陆\n\n\n");
    printf("\t2,本系统可以实现抠抠注册\n\n\n");
    printf("\t3,本系统可以实现抠抠聊天的功能\n\n\n");
    printf("\tt4,本系统可以实现抠抠写日记的功能\n\n\n");
    printf("\t5,本系统可以实现抠抠看日记的功能\n\n\n");
    printf("\t声明:本程序版权归偶所有,想用请联系偶……\n\n\n");
    printf("\t\t\t\t\t如有疑问请联系本人 QQ:59239434\n");
    system("pause");
}
        



void grzx()                                                    /*个人中心*/
{
    system("color 6e");
    while (1)
    {
        system("cls");
        int e;
        printf("\n\t\t\t  欢迎进入个人中心\n\n");
        printf("\t\n\n\n1,聊天:   您可以和MM或GG聊天。\n\n\n2,写日记:您可以在这里书写一天的心情\n\n\n");
        printf("3,看日记:看看昨天的你,会有别样的心情\n\n\n4,注销登录:谢谢使用\n");
        printf("\n\n\n\t\t\t请选择:");
        fflush(stdin);
        scanf("%d",&e);
        switch(e)
        {
            case 1:liaotian();break;
            case 2:fflush(stdin);xieriji();break;
            case 3:kanriji();break;
            case 4:exit(0);
            default :printf("您输入有误,请重新输入");getch();
        }
    }
}






void liaotian()                                            /*聊天函数*/    
{
    system("color 3e");
    system("cls");
    char f[40]={"你是MM还是GG啊,请只写MM或GG"},g[20]={"GG"},h[20],i[20]={"太棒了我是GG"},ll[20];
    char j[20]={"太棒了我是MM"},k[20]={"你叫什么名字?"},l[30]={"我叫芙蓉姐姐啊,认识我把?"},m[20]={"哈哈 我叫刘德华"};
    char n[50]={"嫁给我吧i love u to the dying day"},bb[20],jn[20],yu[20];
    char o[30]={"同意请按1 不同意请按0"},p[4]={"1"},q[30]={"不要害怕我不会伤害你的"};
    char s[40],t[20]={""},u[20]={""},op[10];

    printf("欢迎进入聊天室\n");
    printf("NOW let's begin\n\n");
    Sleep(1000);
    printf("你好啊\n");
    scanf("%s",ll);
    Sleep(500);
    puts(f);
    scanf("%s",h);
    if(strcmp(g,h)!=0)/*和美眉聊天中*/
    {
        puts(i);
        Sleep(100);
        puts(k);
        scanf("%s",bb);
        puts(m);
        Sleep(500);
        puts(n);
        Sleep(100);
        puts(o);
        scanf("%s",s);
            if(strcmp(s,p)==0)
            {
                printf("我这就去找你,等我………\n");
                getch();
                printf("系统提示您对方已经下线,按任意键返回");
                getch();
            }
            else
            {
                printf("你不嫁给我,我还不嫁给你呢!88\n");
                printf("系统提示您对方已经下线,按任意键返回");
                getch();
            }
    }
    
    else
    {                        /*和GG聊天中*/
        Sleep(500);
        puts(j);
        Sleep(100);
        puts(k);
        scanf("%s",jn);
        Sleep(500);
        puts(l);
        scanf("%s",yu);
        fflush(stdin);
        printf("别看我很丑其实我很温柔,你说嘛?'是'还是'不是'");
        fflush(stdin);
        scanf("%s",op);
        if(strcmp(op,u)==0)
        {
            printf("我这就去找你,等我………\n");
            printf("系统提示您对方已经下线,按任意键返回\n");
            getch();
        }
        else
        {
            printf("哼,美女我不理你了");
            printf("系统提示您对方已经下线,按任意键返回");
            getch();
        }
    }
}






void xieriji()    
{                                            /*写日记函数*/
    system("color 8e");
    system("cls");
    FILE *fp;
    char rj[5000];
    if((fp=fopen("rijiben.txt","w"))==NULL)
    {
        printf("不存在日记");
        exit(0);
    }
    else
    {
        printf("开始写日记:");
        gets(rj);
        fputs(rj,fp);
    }
    printf("\n按任意键返回");
    getch();
    fclose(fp);
}





void kanriji()                                /*看日记函数*/
{
    system("color 3e");    
    system("cls");
    char kk[5000];
    FILE *rr;
    if((rr=fopen("rijiben.txt","r"))==NULL)
    {
        printf("无法打开日记本");
        system("pause");
        exit(0);
    }
    else
    {
        fgets(kk,50000,rr);
        printf("请稍等正在载入……………\n");
        Sleep(2000);
        printf("\t");
        printf("%s",kk);
    }
    printf("\n\n按任意键返回");
    getch();
    fclose(rr);
}
默认分类 | 阅读 477 次
文章评论,共0条
游客请输入验证码
文章分类
文章归档
最新评论