标题:求助。如何在双循环里再套个循环
只看楼主
qwj223
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-6-7
 问题点数:0 回复次数:1 
求助。如何在双循环里再套个循环
#include <stdio.h>
#include <stdlib.h>
void stucover()//项目封面
{
    system("cls");//执行DOS清屏命令函数
    printf("\n\n\n");
    printf("\t\t         班级学生成绩管理系统\n\n");
    printf("\t\t             版本号:1.0\n\n");
    printf("\n\n\n\n");
    printf("\t\t              2008年5月\n\n");
    printf("\t\t           程序设计兴趣小组\n");
}
void mainmenu()//项目主菜单
{
    int n;
    system("cls");
    printf("\n\n\n");
    printf("         |* * * * * 学生成绩管理系统 * * * * *|\n");
    printf("         |....................................|\n");
    printf("         |         请选择菜单序号(0~6)        |\n");
    printf("         |....................................|\n");
    printf("         |           1----打开文件            |\n");
    printf("         |           2----保存文件            |\n");
    printf("         |           3----编辑数据            |\n");
    printf("         |           4----显示数据            |\n");
    printf("         |           5----数据计算            |\n");
    printf("         |           6----排序菜单            |\n");
    printf("         |           7----程序说明            |\n");
    printf("         |           0----退出系统            |\n");
    printf("         |....................................|\n");

}
void editmenu()//编辑子菜单
{
    int n;
    system("cls");
    printf("\n\n\n");
    printf("               | * * * * * * 编辑子菜单 * * * * * * |\n");
    printf("               |....................................|\n");
    printf("               |         请选择菜单序号(0~3)        |\n");
    printf("               |....................................|\n");
    printf("               |           1----增加记录            |\n");
    printf("               |           2----删除记录            |\n");
    printf("               |           3----修改记录            |\n");
    printf("               |           0----返回上级菜单        |\n");
    printf("               |....................................|\n");
    printf("\t\t请选择序号:");
    scanf("%d",&n);
    printf("您选择了第%d项!\n",n);
}
void dispmenu()//查看子菜单
 {
   int n;
    system("cls");
    printf("\n\n\n");
    printf("                 | * * * * * * 查看子菜单 * * * * * * |\n");
    printf("                 |....................................|\n");
    printf("                 |         请选择菜单序号(0~6)        |\n");
    printf("                 |....................................|\n");
    printf("                 |           1----查看选定记录        |\n");
    printf("                 |           2----显示全部记录        |\n");
    printf("                 |           3----显示排序记录        |\n");
    printf("                 |           4----显示不及格记录      |\n");
    printf("                 |           0----还回上级菜单        |\n");
    printf("                 |....................................|\n");
    printf("\t\t请选择序号:");
    scanf("%d",&n);
    printf("您选择了第%d项!\n",n);
}
void compmenu()//计算子菜单
{
    int n;
    system("cls");
    printf("\n\n\n");
    printf("         | * * * * * * * * * 计算子菜单 * * * * * * * * * |\n");
    printf("         |................................................|\n");
    printf("         |                请选择菜单序号(0~3)             |\n");
    printf("         |................................................|\n");
    printf("         |             1----计算总成绩和平均成绩          |\n");
    printf("         |             2----计算最高分                    |\n");
    printf("         |             3----计算最低分                    |\n");
    printf("         |             0----返回上级菜单                  |\n");
    printf("         |................................................|\n");
    printf("\t\t请选择序号:");
    scanf("%d",&n);
    printf("您选择了第%d项!\n",n);
}
void sortmenu()//排序子菜单
{
    int n;
    system("cls");
    printf("\n\n\n");
    printf("             |* * * * * 学生成绩管理系统 * * * * *|\n");
    printf("             |....................................|\n");
    printf("             |         请选择菜单序号(0~2)        |\n");
    printf("             |....................................|\n");
    printf("             |           1----按升序排列          |\n");
    printf("             |           2----按降序排列          |\n");
    printf("             |           0----返回上级菜单        |\n");
    printf("             |....................................|\n");
    printf("\t\t请选择序号:");
    scanf("%d",&n);
    printf("您选择了第%d项!\n",n);
}

void Quit(int flag)//退出函数
{
    if(flag==1)
    {
       system("cls");
       printf("\n\n\n\n\n\n\t\t\t操作结束,退出系统!");
       getch();
       system("cls");
       exit(0);//退出程序,返回到操作系统库函数
     }
     else if(flag==0)
     {
         system("cls");
         printf("\n\n\n\n\n\n\t\t\t操作结束,返回上级菜单!");
         getch();
         system("cls");
     }
}
void main()
{
 int choose,editnum,dispnum,compnum,sortnum;//定义5个输入变量
 system("cls");
 stucover();//调用封面菜单
 getch();
 while(1)//外循环
 {
         mainmenu();//调用主菜单函数
         printf("\t\t请输入序号:");
         scanf("%d",&choose);
         printf("您选择了第%d项!\n",choose);
getch();
         switch(choose)//主菜单的switch
         {
         case 1:printf("打开文件!\n");getch();break;
         case 2:printf("保存文件!\n");getch();break;
         case 3:editmenu();getch();break;

         case 4:dispmenu();getch();break;
         case 5:compmenu();getch();break;
         case 6:sortmenu();getch();break;
         case 7:printf("程序说明!\n");getch();break;//程序说明
          case 0:Quit(1);break;
          }//主菜单的switch结束
        }//外循环结束
 }
如何在CASE里再套循环
搜索更多相关主题的帖子: 双循环 
2010-06-07 17:03
韩明海
Rank: 8Rank: 8
等 级:蝙蝠侠
帖 子:253
专家分:749
注 册:2010-4-3
得分:0 
case **:
    for()
    {
        ***;
    }
    break;
2010-06-07 20:13



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




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

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