黑马程序员-if 语句练习

<pre name="code" class="html">------<a href="http://www.itheima.com" target="blank">Java培训、Android培训、iOS培训、.Net培训</a>、期待与您交流! -------


 

/*
 1>	输入一个整数day代表星期几,根据day的值输出对应的星期几,比如day==1,就输出“星期一”
 
 */

#include <stdio.h>
int main()
{
// 1.输入一个整数
    printf("请输入一个整数:\n");
    
    
//2.接收输入的整数
    int day;
    scanf("%d",&day);
    
    
    
//3.判断输出星期几
    if (day % 7 == 1)
    {
        printf("星期一\n");
    }
    
    if (day % 7 == 2)
    {
        printf("星期二\n");
    }
    
    if (day % 7 == 3)
    {
        printf("星期三\n");
    }
    
    if (day % 7 == 4)
    {
        printf("星期四\n");
    }
    
    if (day % 7 == 5)
    {
        printf("星期五\n");
    }
    
    if (day % 7 == 6)
    {
        printf("星期六\n");
    }
    
    if (day % 7 == 0)
    {
        printf("星期日\n");
    }



    return 0;
}
#include <stdio.h>
int main()
{
    //1提示输入
    printf("请输入分数:\n");
    
    //2接收输入
    int score;
    scanf("%d",&score);
    
    //3判断等级
    
    switch (score/10) {
        case 10:
        case 9:
            printf("A\n");
            break;
        case 8:
            printf("B\n");
            break;
        case 7:
            printf("C\n");
            break;
        case 6:
            printf("D\n");
            break;
        
            
        default:
            printf("E\n");
            break;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    /*if (score>=90 && score<=100)
        
    {
        printf("A\n");
    }
    
    else if (score>=80)
        
    {
        printf("B\n");
    }
    
    else if (score>=709)
        
    {
        printf("C\n");
    }
    
    else if (score>=60)
        
    {
        printf("D\n");
    }
    
    else if (score<=59)
        
    {
        printf("E\n");
    }*/

    
    /*if (score>=90 && score<=100)
        
    {
        printf("A\n");
    }
    
    else if (score>=80 && score<=89)
        
    {
        printf("B\n");
    }
    
    else if (score>=70 && score<=79)
        
    {
        printf("C\n");
    }
    
    else if (score>=60 && score<=69)
        
    {
        printf("D\n");
    }
    
    else if (score<=59)
        
    {
        printf("E\n");
    }
    */

    
/*if (score>=90 && score<=100)
        
    {
        printf("A\n");
    }
    
    if (score>=80 && score<=89)
        
    {
        printf("B\n");
    }
    
    if (score>=70 && score<=79)
        
    {
        printf("C\n");
    }

    if (score>=60 && score<=69)
        
    {
        printf("D\n");
    }
    
    if (score<=59)
        
    {
        printf("E\n");
    }*/



    


    return 0;
}

/*2>	输入一个整数month代表月份,根据月份输出对应的季节。
春季:3、4、5
夏季:6、7、8
秋季:9、10、11
冬季:12、1、2
*/


#include <stdio.h>
int main()
{
    printf("请输入一个整数:\n");
    int month;
    scanf("%d", &month);
    if(month==3||month==4||month==5)
    {
        printf("春季\n");
    }
    if(month==6||month==7||month==8)
    {
        printf("夏季\n");
    }
    if(month==9||month==10||month==11)
    {
        printf("秋季\n");
    }
    if(month==1||month==2||month==12)
    {
        printf("冬季\n");
    }




    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值