当前位置: 代码迷 >> C语言 >> 菜菜鸟求助 返回值问题... 祝大家节日愉快
  详细解决方案

菜菜鸟求助 返回值问题... 祝大家节日愉快

热度:361   发布时间:2008-05-02 14:41:31.0
在我这除了你没有定义yesno变量外
运行没有问题,呵呵!!
----------------解决方案--------------------------------------------------------
  好得 我全部贴出来...
#include <stdio.h>
#include <stdlib.h>
void Menu(void);
int number(int EngineerNo);
int Exit(void);

int EngineerNo,EngineerSex,EngineerBirth,EngineerEducation,EngineerWorkYears,yes;

char EngineerName,EngineerHometown,EngineerAddress,EngineerPhone,yesno;

float EngineerBaseSalary;

void main(void)
{
while(1)
    {
    int menu=0;

    printf("\t-----------------------------------------------------\n");
    printf("\t|               软件测试工程师管理系统              |\n");
    printf("\t-----------------------------------------------------\n");
    printf("\t1.输入软件测试工程师资料\n");
    printf("\t2.删除指定测试工程师资料\n");
    printf("\t3.查询软件测试工程师资料\n");
    printf("\t4.修改软件测试工程师资料\n");
    printf("\t5.计算测试工程师的月薪水\n");
    printf("\t6.保存新添加大工程师资料\n");
    printf("\t7.对测试工程师信排序(1编号升序,2姓名升序, 3工龄升序)\n");
    printf("\t8.输出所有测试工程师信息\n");
    printf("\t9.清空所有测试工程师数据\n");
    printf("\t10.打印软件测试工程师 数据报表\n");
    printf("\t11.从文件重新导入测试工程师数据\n");
    printf("\t0.结束(编辑工程师信息后提示保存)\n");
    printf("\n\n");
    
    
    printf("\t请输入你的选择:",menu);
    scanf("%d",&menu);
    fflush(stdin);
    {
        switch(menu)
        {
            case 1:
                Menu();
                break;

            case 2:
                printf("\t删除指定测试工程师资料*****功能完善中!*****\n");
                break;

            case 3:
                printf("");
                break;

            case 4:
                printf("\t修改软件测试工程师资料*****功能完善中!*****\n");
                break;

            case 5:
                printf("");
                break;
   
            case 6:
                printf("\t保存新添加大工程师资料*****功能完善中!*****\n");
                break;

            case 7:
                printf("\t对测试工程师信排序(1 编号升序,2 姓名升序, 3 工龄升序)*****功能完善中!*****\n");
                break;

            case 8:
                printf("\t输出所有测试工程师信息*****功能完善中!*****\n");
                break;

            case 9:
                printf("\t清空所有测试工程师数据\n");
                break;

            case 10:
                printf("\t打印软件测试工程师 数据报表*****功能完善中!*****\n");
                break;
  
            case 11:
                printf("\t从文件重新导入测试工程师数据*****功能完善中!*****\n");
                break;
  
            case 0:
                Exit();
                printf("\t11111111111111111111-======%d\n",yes);
                if (yes==0)
                    return;
                break;
   
            default:
                printf("\t您输入错误,系统进入主菜单\n");
                break;    


                

                
                    
        }

    }
    
    }
}



/*********工程师输入信息*********/

void Menu(void)
{
    printf("\t确定输入工程师资料?(y/n)");
        while(1)
                {
                scanf("%c",&yesno);
                    fflush(stdin);
                    switch(yesno)    
                    {
                        case 'y':
                            printf("\t请输入工程师编号(1-2000):");
                                number(EngineerNo);

                            printf("\t请输入工程师姓名:");
                                scanf("%c", &EngineerName);
                                fflush(stdin);

                            printf("\t请输入工程师性别:");
                                scanf("%d",&EngineerSex);
                                fflush(stdin);
                            
                            printf("\t请输入工程师生日:");
                                scanf("%d",&EngineerBirth);
                                fflush(stdin);

                            printf("\t请输入工程师籍贯:");
                                scanf("%c",&EngineerHometown);
                                fflush(stdin);

                            printf("\t请输入工程师学历:");
                                scanf("%d",&EngineerEducation);
                                fflush(stdin);

                            printf("\t请输入工程师地址:");
                                scanf("%c",&EngineerAddress);
                                fflush(stdin);

                            printf("\t请输入工程师电话:");
                                scanf("%c",&EngineerPhone);
                                fflush(stdin);

                            printf("\t请输入工程师工龄:");
                                scanf("%d",&EngineerWorkYears);
                                fflush(stdin);

                            printf("\t请输入工程师基本薪水:");
                                scanf("%f",&EngineerBaseSalary);
                                fflush(stdin);
                            
                            break;

                        case 'n':
                            printf("\t返回主菜单\n\n");
                            break;

                        default:
                            printf("\t你输入错误请重新输入(y/n):");
                    }
                    break;
                }
}


/*************判断编号是否输入正确*********/

int number(int EngineerNo)
{
    while(1)
    {
    scanf("%d",&EngineerNo);
    fflush(stdin);
    {
        if ( EngineerNo<=2000 &&EngineerNo>0 )
            return EngineerNo;
        else
            printf("\t您输入错误请重新输入编号: ");
    }
    }
}


/*************判断性别是否输入正确**********/

int gender(int sex)
{
    while(1)
    {    
    switch(sex)
    {
        case 0:
            break;
        case 1:
            break;      
        default:
            printf("\t您输入错误,请重新输入性别: ");
            continue;
    }
    break;
    }
}


/*********保存退出模块*********/

int Exit(void)
{
    printf("\t你确定保存工程师资料并退出(y/n)?");
        scanf("%c",&yesno);
            fflush(stdin);
            switch(yesno)     
            {   
                case 'y':
                case 'Y':
                    printf("\t保存成功!请按任意键退出!\n ");
                    return 0;
                case 'n':
                case 'N':
                    printf("\t返回菜单\n");
                    return 1;
            }
}
----------------解决方案--------------------------------------------------------
问题大概是你根本没有用到Exit()的返回值,后面的输出是变量yes,而整个过程我也没看到变量yes的利用//还有全局变量yes的默认值是0(C中全局变量没有默认值,最新标准不知道规定没有,所以这个和编译器有一定关系...最后我推断是你这里写错了,应该写成:
  yes=Exit();
----------------解决方案--------------------------------------------------------
xiao看了下你程序中错误错的哈真不少 汗..好好检查  不是你说叫他跳出就跳出的看看你的循环 没编译器运行 只能看  程序整洁 很好 但是很邋遢
----------------解决方案--------------------------------------------------------
我现在就是怎么跳出循环和怎么结束循环没弄明白..
  谁能给我讲解下 刚刚运行了下 发现问题真的一大堆
----------------解决方案--------------------------------------------------------
你的答案问题太多了
还有书上的题目别到这里着答案
就比如说你的输入格式错误
很多地方会产生问题
----------------解决方案--------------------------------------------------------
你在青鸟学测试的吧
这是BTEST课程的作业
----------------解决方案--------------------------------------------------------
全局变量太多
很多没有去合理赋初值。
你先多看看你们的教程吧
问题一点点来
----------------解决方案--------------------------------------------------------
指出点错误给你看下  别的自己找找看
int gender(int sex)
{
    while(1)
    {   
    switch(sex)
    {
        case 0:
            break;
        case 1:
            break;      
        default:
            printf("\t您输入错误,请重新输入性别: ");
            continue;
    }
    break;
    }
}
首先函数是 有返回制的 你的RETURN那里去了 还有 你怎么跳出的循环 恩 跳出循环 我写个简单的给你看下
         
do{switch(n)
        {
          case 0:  break;
         case 1: a++; break;
     case 2: b++; break;
          case 3: c++; break;
          case 4: d++; break;
          default : printf("输入有错误,请从新输入\n");
        }
      
    }while(n);
  没编译器只有手写没法子 将就下把
----------------解决方案--------------------------------------------------------
[bo]以下是引用 [un]yd4433[/un] 在 2008-5-2 21:30 的发言:[/bo]

指出点错误给你看下  别的自己找找看
int gender(int sex)
{
    while(1)
    {   
    switch(sex)
    {
        case 0:
            break;
        case 1:
            break;      
        defaul ...



弄个最简单的吧 怎么
样让我我上面退出模块  有返回值 要么是1 要么是0
----------------解决方案--------------------------------------------------------