把它翻译成文字。例如命名行星然后给出关于该行星的事实 [英] Translate this into words. e.g. naming a planet and then gives a fact about that planet

查看:153
本文介绍了把它翻译成文字。例如命名行星然后给出关于该行星的事实的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <cs50.h>
#include <stdio.h>

int main(void)
{
    // ask for an integer
    printf("how old are you?\n");
    int n = GetInt();
    
    // analyse users input
    if (n >= 1 && n <= 12)
    {
        printf("you're still a baby\n");
    
    }
    else if (n >= 13 && n <= 19)
    {
        printf("you're a teenager\n");
    }
    else if (n >= 20 && n <= 39)
    {
        printf("adult?\n");
    }
    else if (n >= 40 && n <= 100)
    {
        printf("Damn, you old!\n");
    }
    else if (n > 101)
    {
        printf("How are you not dead?\n");
    }
}





我的尝试:





What I have tried:

#include <stdio.h>
#include <cs50.h>
#include <string.h>

int main(void)
{
    // choose a planet
    printf("Choose a planet\n");
    
    if (strncmp = "Mercury")
    {
        printf("Mercury takes 87.9 Earth days to complete its orbit around the Sun");
    }</string.h></cs50.h></stdio.h></stdio.h></cs50.h>

推荐答案

if (strncmp = "Mercury")



甚至不会编译,更不用说产生有意义的结果了。请参阅 strncmp,wcsncmp,_mbsncmp,_mbsncmp_l [ ^ ]


这篇关于把它翻译成文字。例如命名行星然后给出关于该行星的事实的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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