| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 574 人关注过本帖
标题:高手救急!!!
只看楼主 加入收藏
zwh811
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-9-23
收藏
 问题点数:0 回复次数:2 
高手救急!!!
能运行,但是黑屏一闪就跳出来!!!

#include "stdio.h"
#include "conio.h"
#include "string.h"


typedef struct /*定义结构体数组*/
{
int stu_NO[10];  /*学号*/
char stu_Name[21]; /*姓名*/
int stu_Phone[10];   /**/
char stu_Address[21]; /**/
}Student;

Student stu[80]; /*结构体数组变量*/
int iIndex;

int MainMenuChoice(void)
{
    int iChoice;
    clrscr();
    printf("\n\WELCOME TO STUDENT ARCHIVES SYSTEM");
    printf("\n\n\n\t            MAIN MENU ");
    printf("\n\t                1.Input students' information.");
    printf("\n\t                2.Append students' information.");
    printf("\n\t                3.Amend students' information.");
    printf("\n\t                4.Delete students' information.");
    printf("\n\t                5.Show students' information.");
    printf("\n\t                6.Quit.");
    printf("\n\n\n\n\n\t      Enter choice(1-6)==>");
    scanf("%d",&iChoice);
    fflush(stdin);
    if(iChoice<1||iChoice>6)
    {
        printf("You input a error number\n\n       Enter choice(1-6)==>");
        scanf("%d",&iChoice);
        fflush(stdin);
     }
     return iChoice;

}

int InputDate(void)
{
    int iIndex=0;
    int iA=1;
    char cChoice='Y';
    if(cChoice=='Y'&&cChoice=='y')
    {
        printf("Please input the %d studend name ",iA);
        scanf("%20[^\n]",stu[iA].stu_Name);
        fflush(stdin);
        printf("\n\nPlease input the %d studend NO ",iA);
        scanf("%d",&stu[iA].stu_NO);
        fflush(stdin);
        printf("\n\nPlease input the %d studend address ",iA);
        scanf("%20[^\n]",stu[iA].stu_Address);
        fflush(stdin);
        printf("\n\nPlease input the %d studend phone number ",iA);
        scanf("%d",&stu[iA].stu_Phone);
        iIndex++;
        printf("\n\n\n\nThe %d studend information is:",iA);
        printf("Name:%s\nNo:%d\nPhone:%d\nAddress%s",stu[iA].stu_Name,stu[iA].stu_NO,stu[iA].stu_Phone,&stu[iA].stu_Phone);
        printf("Enter 'Y' or'y' to input information ,enter other to the main menu. ");
        clrscr();
     }
     return iIndex;

}


int AppendDate(void)
{


    char cChoice;
    cChoice='Y';
    if(cChoice=='Y'&&cChoice=='y')
    {
        printf("Please input the %d studend name ",iIndex);
        scanf("%20[^\n]",stu[iIndex].stu_Name);
        fflush(stdin);
        printf("\n\nPlease input the %d studend NO ",iIndex);
        scanf("%d",&stu[iIndex].stu_NO);
        fflush(stdin);
        printf("\n\nPlease input the %d studend address ",iIndex);
        scanf("%20[^\n]",stu[iIndex].stu_Address);
        fflush(stdin);
        printf("\n\nPlease input the %d studend phone number ",iIndex);
        scanf("%d",&stu[iIndex].stu_Phone);
        printf("\n\n\n\nThe %d studend information is:",iIndex);
        printf("Name:%s\nNo:%d\nPhone:%d\nAddress%s",stu[iIndex].stu_Name,stu[iIndex].stu_NO,stu[iIndex].stu_Phone,&stu[iIndex].stu_Phone);
        iIndex++;
        printf("\n\n\n Enter 'Y' or'y' to input information ,enter other to the main menu. ");
    }
    iIndex=iIndex-1;
    return iIndex;
}


int SearchChoiceMeun(void)
{
    int iChoice;
    printf("   Pease choice the way to do");
    printf("     1.By name.");
    printf("     2.BY NO. ");
    scanf("%d",&iChoice);
    fflush(stdin);
    if(iChoice<0&&iChoice>2)
    {
        printf("You input a wrong number,please input(1-2)");
        scanf("%d",&iChoice);
        fflush(stdin);
    }
    return iChoice;

}


void AmendSearchByName(void)
{
    int iA=0;
    char stu_NAME[21];
    printf("Please input the name of the student whoes want to Amend ");
    scanf("%20[^\n]",stu_NAME);
    while(iA<iIndex+1)
    {
        if(strcmp(stu_NAME,stu[iA].stu_Name)==0)
        {
            printf("\n\nPlease input the %d studend address ",iA);
            scanf("%20[^\n]",stu[iA].stu_Address);
            printf("\n\nPlease input the %d studend phone ",iA);
            scanf("%d",&stu[iA].stu_Phone);
            fflush(stdin);

         }
         iA++;
    }
}

void AmendSearchByNo(void)
{
    int iA=0;
    char stu_no[13];
    printf("Please input the NO of the student whoes want to Amend ");
    scanf("%d",&stu_no);
    for(iA=0;iA<iIndex+1;iA++)
    {
        if(strcmp(stu_no,stu[iA].stu_NO)==0)
        {
            printf("\n\nPlease input the %d studend address ",iA);
            scanf("%20[^\n]",stu[iA].stu_Address);
            printf("\n\nPlease input the %d studend phone ",iA);
            scanf("%d",&stu[iA].stu_Phone);
            fflush(stdin);
         }

     }
}


void AmendDate(void)
{
    int iChoice;
    iChoice=SearchChoiceMeun();
    while(iChoice!=3)
    {
        switch(iChoice)
        {
            case 1:
            AmendSearchByName();
            break;
            default:
            AmendSearchByNo();
            break;
         }
    }
}


int DeleteSearchByName(void)
{
    int iA=0;
    int j;
    char stu_NAME[21];
    printf("Please input the name of the student whoes want to delete ") ;
    scanf("%20[^\n]",stu_NAME);
    while(strcmp(stu[iA].stu_Name,stu_NAME)!=0&&iA<iIndex)
    iA++; /*查找判断*/
    if(iA==iIndex)
    {
        printf("\t\t\tnot find!\n"); /*返回失败信息*/
        return(iIndex);
     }
     for(j=iA;j<iIndex-1;j++) /*删除操作*/
     {
          strcpy(stu[iA].stu_Name,stu[iA+1].stu_Name);
          strcpy(stu[iA].stu_NO,stu[iA+1].stu_NO);
          strcpy(stu[iA].stu_Phone,stu[iA+1].stu_Phone);
          strcpy(stu[iA].stu_Address,stu[iA+1].stu_Address);
      }
       iIndex--;
}


void DeleteSearchByNo(void)
{
    int iA=0;
    char stu_no[13];
    printf("Please input the NO of the student whoes want to delete ");
    scanf("%d",stu_no);
    while(iA<iIndex+1)
    {
        if(stu_no==stu[iA].stu_NO)
        {
             for(;iA<iIndex+1;iA++)
            {
                strcpy(stu[iA].stu_Name,stu[iA+1].stu_Name);
                strcpy(stu[iA].stu_NO,stu[iA+1].stu_NO);
                strcpy(stu[iA].stu_Phone,stu[iA+1].stu_Phone);
                strcpy(stu[iA].stu_Address,stu[iA+1].stu_Address);
             }
         }
     }
}



void DeleteDate(void)
{
    int iChoice;
    iChoice=SearchChoiceMeun();
    while(iChoice!=3)
    {
        switch(iChoice)
        {
            case 1:
            DeleteSearchByName();
            break;
            default:
            DeleteSearchByNo();
            break;
        }
     }
}




void ShowDate(void)
{
    int iA;
    printf("NO   NAME     PHONE    ADDRESS\n\n\n ");
    for(iA=0;iA<iIndex+1;iA++)
    printf(":%d\n:%s\n:%d\n%s",stu[iA].stu_NO,stu[iA].stu_Name,stu[iA].stu_Phone,stu[iA].stu_Address);
}


main()
{

   char cChoice='Y';
   if(cChoice=='Y'&&cChoice=='y')
   {
       int iChoice;
       iChoice=MainMenuChoice();
       while(iChoice!=7)
       {
            switch(iChoice)
            {
                case 1:
                InputDate();
                break;
                case 2:
                AppendDate();
                break;
                case 3:
                AmendDate();
                break;
                case 4:
                DeleteDate();
                break;
                default:
                ShowDate();
                break;
            }
            iChoice=MainMenuChoice();
      }
      getch();
      return;

    }
}
搜索更多相关主题的帖子: void 姓名 include 结构体 
2008-10-12 00:56
知道不知道
Rank: 1
等 级:新手上路
威 望:2
帖 子:183
专家分:0
注 册:2008-10-4
收藏
得分:0 
看到第一行的“黑屏一闪”就不要再往下看了,肯定是getch()没执行
2008-10-12 00:59
kd0376
Rank: 1
等 级:新手上路
帖 子:92
专家分:0
注 册:2007-12-7
收藏
得分:0 
。。。。没错误~~但警告好多
2008-10-12 01:05
快速回复:高手救急!!!
数据加载中...
 
   



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

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