标题:电影院售票管理系统(顺序表实现))
只看楼主
liuxiansheng
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2018-6-7
结帖率:0
 问题点数:0 回复次数:0 
电影院售票管理系统(顺序表实现))
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
struct movie
{
    char num[10];
    char name[10];
    char s[10];
    int time;;
    int set;
    float money;
}
movie[100];
void Menu()
{
    printf("\t\t======================================================\n");
    printf("\t\t||                 电影院售票管理系统                 ||\n");
    printf("\t\t||          *********************************       ||\n");
    printf("\t\t||          *         ★ 功能菜单 ★        *       ||\n");
    printf("\t\t||          *********************************       ||\n");
    printf("\t\t||                  1.添加电影记录                  ||\n");
    printf("\t\t||                  2.查询电影票房                  ||\n");
    printf("\t\t||                  3.删除电影记录                  ||\n");
    printf("\t\t||                  4.修改电影记录                 ||\n");
    printf("\t\t||                  5.输出电影信息                  ||\n");
    printf("\t\t||                  6.退出学生成绩管理系统          ||\n");
    printf("\t\t======================================================\n");
}
void Input()//1.添加电影记录
{
    printf("\t\t请按顺序输入票号,电影名称,开场时间,放映厅,票房,不同项之间用空格间隔开:\n");
    printf("\t\t电影名称 票号 票房\n");
    for(int i=0;i<3;i++)
    {
        printf("\t\t");
        scanf("%s%s%d%f%f%f", &movie[i].num, &movie[i].name, &movie[i].time, &movie[i].s,&movie[i].money );
    }
        printf("\t\t提示:电影记录存入完毕!\n\n");
}
void Find()//2.查询电影票房
{
    int a,i;
    float sum, ave;
    printf("\t\t======================================================\n");
    printf("\t\t||            ※欢迎进入电影信息查询系统※          ||\n");
    printf("\t\t||                1.按电影名称查找                ||\n");
    printf("\t\t||                2.按票号查找                  ||\n");
    printf("\t\t======================================================\n");
    printf("\t\t>>>请选择1--2:");
     scanf("%d", &a);
    switch (a)
    {
    case 1://1.按电影名称查找
    {
        char name[10];
        printf("\t\t>>>请输入要查找的电影的名称:");
        scanf("%s", name);
        printf("\t\t>>>以下是%s电影的信息:\n\n",name);
        for ( i=0;i<3;i++)
        {
            if (strcmp(name, movie[i].name) == 0)
            {
                sum =movie[i].money;
                printf("\t\t电影名称\t票号\t票房\n");
                printf("\t\t%s\t%s\t %d\t %.2f\t\t  %.2f\t\t %.2f\t\t%.2f\t\t%.2f\n\n", movie[i].name, movie[i].num, movie[i].money, sum);
            }

        }
               
    }break;
    case 2://2.按票号查找
    {
        char Num[10];
        printf("\t\t>>>请输入要查找的电影的票号:");
        scanf("%s", Num);
        printf("\t\t>>>以下是%s号电影的信息:\n\n",Num);
        for ( i = 0; i < 3; i++)
        {
            if (0 == strcmp(Num, movie[i].num))
            {
               sum =movie[i].money;
                printf("\t\t电影名称\t票号\t票房\n");
                printf("\t\t%s\t%s\t %d\t %.2f\t\t  %.2f\t\t %.2f\t\t%.2f\t\t%.2f\n\n", movie[i].name, movie[i].num, movie[i].money, sum);
            }
            
        }
    break;
    }
void Delete()//3.删除电影记录
{
    int i;
    char num[10];
    printf("\t\t>>>请输入要删除电影的票号:");
    scanf("%s", &num);
    for (i = 0; i<3; i++)
        if (strcmp(num, movie[i].num) == 0)
        {
                movie[i] = movie[i + 1];
                i++;
        }
    printf("\t\t>>>提示:%s号电影信息已成功删除!\n\n", num);
}
void Modify()//4.修改电影记录
{
    char num[10];
    printf("\t\t>>>请输入要修改的电影的票号:");
    scanf("%s", &num);
    for (int i=0;i<3;i++)
        if (strcmp(movie[i].num, num) == 0)
        {   
            printf("\t\t>>>已查找到票号为%s的电影,请输入新的信息,不同项之间用空格间隔开:\n",id);
            printf("\t\t电影名称 票号 开场时间 放映厅 票房\n");
            printf("\t");
            scanf("%s%s%d%f%f%f", &movie[i].name, &movie[i].num, &movie[i].time, &movie[i].s, &movie[i].money);
            printf("\t\t>>>提示:学号为%s的学生信息已更新!\n\n", id);
        }
}
void Output()//5.输出电影信息
{
    float sum;
    printf("\t\t电影名称\t票号\t开场时间\t放映厅\t票房\n");
    for (int i = 0; i < 3; i++)
    {
        sum =movie[i].money;
        printf("\t\t%s\t%s\t %d\t %.2f\t\t  %.2f\t\t %.2f\t\t%.2f\t\t%.2f\n\n", movie[i].name, movie[i].num,movie[i].time,movie[i].s movie[i].money,sum);
    }
}
int main()
{
    int selection;
    while (true)
    {
        Menu();
        printf("\t\t>>>请选择1--6:");
        scanf("%d", &selection);
        printf("\n");
        switch (selection)
        {
        case 1:  Input();     break;
        case 2:  Find();      break;
        case 3:  Delete();     break;
        case 4:  Modify();   break;
        case 5:  Output();    break;
        case 6:
            printf("\n\t\t>>>您已成功退出电影院售票管理系统,感谢使用!\n\n");
            exit(0);
            break;
        default:
            printf("\n\t\t>>>输入有误,请重新输入!\n\n");
        }
    }
    return 0;
}
为什么总是显示有错误
搜索更多相关主题的帖子: 电影 num name printf || 
2018-06-07 18:46



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-487705-1-1.html




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

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