下面的代码不能正常工作...... plz建议纠正...... [英] below code is not working properly......plz suggest the correction......

查看:74
本文介绍了下面的代码不能正常工作...... plz建议纠正......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include<stdio.h>
int main()
{
    char gender,qual;
    int yos,sal=0;
    printf("enter gender qualification year of service and sal of employe\n");
    scanf("%c%c%d%d",&gender,&qual,&yos,&sal);

    if (gender=='M')
    {
        if((yos>=10)&&(qual=='pg'))
            sal=15000;
            else if ((yos>=10)&&(qual=='g')||(yos<10)&&(qual=='pg'))
            sal=10000;
            else if ((yos<10)&&(qual=='g'))
            sal=7000;
    }
    else if ((yos>=10)&&(qual=='pg'))
    sal=12000;
    else if ((yos>=10)&&(qual=='g'))
    sal=9000;
    else if ((yos<10)&&(qual=='pg'))
    sal=10000;
    else if((yos<10)&&(qual=='g'))
    sal=6000;

    printf("sal of employe is=%d\n",sal);
    return 0;

}

推荐答案

工作不正常不是搜索错误的好起点。你能不能更具体一点。



我能马上看到的是条件

"Is not working properly" is not a good starting point to search for an error. Could you please be a little more specific.

What I can see right away is that the condition
qual=='pg'


如果qual是char类型,则
无法工作。 qual 只能存储一个字符!


这篇关于下面的代码不能正常工作...... plz建议纠正......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆