| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 265 人关注过本帖
标题:C语言编程、、
只看楼主 加入收藏
xiaoku889109
Rank: 2
等 级:论坛游民
帖 子:7
专家分:25
注 册:2010-5-15
收藏
 问题点数:0 回复次数:0 
C语言编程、、
想编个管理系统的程序、、才弄了一点点、、就出错了、、杯具啊、、
大家帮帮忙啊、、谢谢了
#include<stdio.h>
#include<conio.h>
#include<malloc.h>
#include<stdlib.h>
typedef struct students
{
    char name[15];
    struct studentMessage
    {
       char sex;
       int  age;
       float height;
       float weight;
       }Mess;
    struct students *ahead;
    struct students *next;
}STU;
void CreatMessage(STU *head);
void FindMessage(void);
void PrintMessage(void);
void AddMessage(void);
void DeleteMessage(void);
void main()
{
    STU *head;
    int selectionNumber;
    char choiceForExit,choice;
    printf("************************************\n");
    printf("*                                  *\n");
    printf("*  Students Administration System  *\n");
    printf("*                                  *\n");
    printf("************************************\n\n");
    printf("Look this selection!\nWould you like to make a selection?\n");
    printf("Please enter your choice:\n\n");
    while(1)
    {
       clrscr();
       printf("\t\t************************************\n");
       printf("\t\t*                                  *\n");
       printf("\t\t*  Students Administration System  *\n");
       printf("\t\t*                                  *\n");
       printf("\t\t************************************\n\n");
       printf("\t\tLook this selection!\n\t\tWould you like to make a selection?\n");
       printf("\t\tPlease enter your choice:\n\n");
       printf("\t\t\t1 : Creat Message\n");
       printf("\t\t\t2 : Find Message\n");
       printf("\t\t\t3 : Print Message\n");
       printf("\t\t\t4 : Add Message\n");
       printf("\t\t\t5 : Delete Message\n");
       printf("\t\t\t6 : Exit\n\n\t\tYour choice: ");
       scanf("%d",&selectionNumber);
       switch(selectionNumber)
       {
           case 1:
                  printf("\t\tDo you want to Creat one?(Y\\N)\n\t\t");
                  choice=getche();
                  if(tolower(choice)=='n')
                    head=NULL;
                  else
                    CreatMessage(head); /*创建学生信息*/
                    break;
           case 2:
                  FindMessage();  break;
           case 3:
                  PrintMessage(); break;
           case 4:
                  AddMessage();   break;
           case 5:
                  DeleteMessage();break;
           case 6:
                  printf("\n\n\t\tDo you really want to exit? (N\\Y)\n\t\t");
                  choiceForExit=getche();
                  if(tolower(choiceForExit)=='y')
                      exit(0);
                  else
                     break;
           default :
                  break;
        }
    }
  getch();
}

/*创建学生信息*/
void CreatMessage(STU *head)
{
      STU *creat;
      char choice;
      clrscr();
      creat=(STU *)malloc(sizeof(STU)); /*分配空间*/
      head=creat;
      if(!creat)   /*判断是否为NULL*/
      {
         printf("\t\tMemory limit,can not creat!\n");
         exit(0);
       }
      else        /*输入信息*/
      {
         printf("\n\n\t\tPlease enter Name: ");
         scanf("%s",creat->name);  
         printf("\n\t\tB or G? : ");/*运行到这里自动关闭了为什么啊?*/
         creat->Mess.sex=getchar();   
         printf("\n\t\tWhat's height? : \n");
         scanf("%f",&creat->Mess.height);
         printf("\n\t\tAnd Weight? : ");
         scanf("%f",&creat->Mess.weight);
         while(1)
         {
            clrscr();
            printf("\t\tWould you like to creat more?(Y\\N)\n");
            scanf("%c",&choice);
            if(tolower(choice)=='n')
            {
               creat->next=NULL;
               break;
             }
            else
            {
               creat->next=(STU *)malloc(sizeof(STU));
               if(!creat->next==NULL)
               {
                   printf("\t\tMerry out!\n");
                   break;
                }
               else
               {
                   creat->next->ahead=creat;
                   creat=creat->next;
                   printf("\n\t\tPlease enter Name: ");
                   scanf("%s",creat->name);
                   printf("\n\t\tB or G? : ");
                   scanf("%d",&creat->Mess.sex);
                   printf("\n\t\tWhat's height? : ");
                   scanf("%f",&creat->Mess.height);
                   printf("\n\t\tWeight : ");
                   scanf("%f",&creat->Mess.weight);
                   printf("\n\t\t");
                }
                creat=NULL;
              }

       }
      }
}
              
         
         
      
      




void FindMessage(void)
{
}


void PrintMessage(void)
{
}


void AddMessage(void)
{
}


void DeleteMessage(void)
{
}            
搜索更多相关主题的帖子: C语言 
2010-05-15 09:51
快速回复:C语言编程、、
数据加载中...
 
   



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

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