m0_74082038 2022-10-04 22:20 采纳率: 50%
浏览 329
已结题

大一的问题,希望可以得到答案的

大一新生,全英文教学,因为我们不允许用if语句,所以有些不知道如何做

img

img

img

img

img

img

  • 写回答

12条回答 默认 最新

  • _GX_ 2022-10-04 23:14
    关注

    1

    #include <stdio.h>
    
    int main()
    {
        int age;
        printf("Please enter your age: ");
        scanf("%d", &age);
        age < 18 ? printf("You are not eligible for voting as your age is %d\n", age)
                 : printf("You are eligible for vote as your age is %d, which is more than or equal to 18\n", age);
        return 0;
    }
    

    2

    #include <stdio.h>
    
    int main()
    {
        char c;
        printf("Please enter a character: ");
        scanf("%c", &c);
        int lowercase = c >= 'a' ? (c <= 'z' ? 1 : 0) : 0;
        int uppercase = c >= 'A' ? (c <= 'Z' ? 1 : 0) : 0;
        (lowercase || uppercase) ? printf("%c is an alphabet", c) : printf("%c is not an alphabet", c);
        return 0;
    }
    

    3

    #include <stdio.h>
    
    int main()
    {
        double temperature;
        printf("Please enter a temperature in centigrade: ");
        scanf("%lf", &temperature);
        printf("Temperature in Fahrenheit is: %.2lf\n", temperature * 9.0 / 5.0 + 32.0);
        temperature <= 15.0 ? printf("I am feeling cold\n")
                            : (temperature <= 25.0 ? printf("I am feeling okay, the temperature is fine\n")
                                                   : printf("I am feeling warm!\n"));
        return 0;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(11条)

报告相同问题?

问题事件

  • 系统已结题 10月18日
  • 已采纳回答 10月10日
  • 修改了问题 10月4日
  • 修改了问题 10月4日
  • 展开全部

悬赏问题

  • ¥15 关于博途V17进行仿真时无法建立连接问题
  • ¥15 请问下这个红框里面是什么文档或者记事本编辑器
  • ¥15 机器学习教材中的例题询问
  • ¥15 求.net core 几款免费的pdf编辑器
  • ¥15 为什么安装HCL 和virtualbox之后没有找到VirtualBoxHost-OnlyNetWork?
  • ¥15 C# P/Invoke的效率问题
  • ¥20 thinkphp适配人大金仓问题
  • ¥20 Oracle替换.dbf文件后无法连接,如何解决?(相关搜索:数据库|死循环)
  • ¥15 数据库数据成问号了,前台查询正常,数据库查询是?号
  • ¥15 算法使用了tf-idf,用手肘图确定k值确定不了,第四轮廓系数又太小才有0.006088746097507285,如何解决?(相关搜索:数据处理)