标题:新手 大神门能不能看一下
只看楼主
YangJinHan
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2017-5-28
结帖率:0
已结贴  问题点数:20 回复次数:2 
新手 大神门能不能看一下
#include <stdio.h>
int main( )
{
    int gender,age;
    scanf("%c %d",&gender,&age);
    double mancost,womancost,
    child1,child2,
    manold,womanold,
    charge,charge1,charge2,charge3,charge4,charge5,charge6;
    charge=0.15;
    mancost=80;
    womancost=70;
    child1=mancost*0.08;
    child2=womancost*0.07;
    manold=mancost*0.09;
    womanold=womanold*0.08;
    charge1=mancost*charge;
    charge2=womancost*charge;
    charge3=child1*charge;
    charge4=child2*charge;
    charge5=manold*charge;
    charge6=womanold*charge;
    if(gender=='f'||gender=='F')
    {           
                   if(age<=18)
                {
                           printf("您的总费用为:%f\n",child2-charge4);
                   }
                  else if(age>=70)
                  {
                        printf("您的总费用为:%f\n",womanold-charge6);
                  }
                 else
                 {
                          printf("您的总费用为:%f\n",womancost-charge2);
                 }
    }
    else if(gender=='m'||gender=='M')
    {                 
                if(age<18)
                {
                    printf("您的总费用为:%f\n",child1-charge3);
                }
                   else if(age>=70)                 
                {
                      printf("您的总费用为:%f\n",manold-charge5);
                }                     
                else
                {
                     printf("您的总费用为:%f\n",mancost-charge1);
                }      
       }
    else
    {
             printf("您输入的性别不合法,请重新输入。");
    }

   
    return 0;
               
  
}

没报错 但是不知道为什么就跳过前两个选择 不管怎么输都只显示"您输入的性别不合法,请重新输入。"
搜索更多相关主题的帖子: include charge double 
2017-05-28 09:31
yangfrancis
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:贵宾
威 望:141
帖 子:1510
专家分:7661
注 册:2014-5-19
得分:20 
int gender变成char gender
2017-05-28 09:36
YangJinHan
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2017-5-28
得分:0 
回复 2楼 yangfrancis
谢谢!
2017-05-28 10:29



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




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

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