会员等级的分类判断任务实现

 zhushican   2022-09-04 19:58   318 人阅读  0 条评论

微软雅黑, 黑体, Arial, Helvetica, sans-serif; font-size: 18px; background-color: rgb(255, 255, 255);">步骤1:启动Visual C++ 6.0

微软雅黑, 黑体, Arial, Helvetica, sans-serif; font-size: 18px; background-color: rgb(255, 255, 255);">步骤2:新建C语言源程序文件(*.c

会员等级的分类判断任务实现

步骤3:在C程序文件中,输入如下代码:

#include "iostream.h"

int main()

{

    int Credit;

    cout<<"请输入该会员的积分:";

    cin>>Credit;

    if(Credit>0&&Credit<1000)

    cout<<"普通会员!"<<endl;

    elseif(Credit<5000)

    cout<<"银卡会员 "<<endl;

    elseif(Credit<10000)

    cout<<"金卡会员!"<<endl;

    else cout<<"贵宾卡会员!"<<endl;

    return 0;

}

#include "iostream.h"

int main()

{

    int Credit;

    cout<<"请输入该会员的积分:";

    cin>>Credit;

    switch(Credit/1000)

    {

       case 0:cout<<"普通会员! "<<endl;  break;

       case 1:

       case 2:

       case 3:

       case 4:cout<<"银卡会员! "<<endl;   break;

       case 5:

       case 6:

       case 7:

       case 8:

       case 9:cout<<"金卡会员! "<<endl;   break;

       default:cout<<"贵宾卡会员!"<<endl;

    }

}

步骤4:编译连接

步骤5:执行运行结果如下所示:

请输入该会员的积分:2688

银卡会员


本文地址:http://www.sclingchen.com/post/142.html
版权声明:本文为原创文章,版权归 zhushican 所有,欢迎分享本文,转载请保留出处!

评论已关闭!