有关编程的问题 [英] Question about programming

查看:64
本文介绍了有关编程的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include <stdlib.h>
#include <stdio.h>
int main (){
int x,y,z;
scanf("%d%d%d",x,y,z);
if (x>y)
{
    if (x>z)
    {
        printf("%d",x);
        if (y>z)
        {
            printf("%d%d",y,z);
        }
        else
        {
            printf("%d%d",z,y);
        }
    }
    else
        printf("%d%d%d",z,x,y);
}
else
{
    if (y>z)
    {
        printf("%d",y);
        if (x>z)
        {
            printf("%d%d",x,z);
        }
        else
        {
            printf("%d%d",z,x);
        }
    }
    else
    {
        printf("%d%d%d",z,y,x);
    }
}
}




当我运行该程序时,它总是告诉我我遇到了错误的内存.




When I run this program it always tell me I have run into the wrong memory.

推荐答案

您必须将参数作为指针传递给scanf,以便它可以写入变量表示的内存,而不是变量值表示的内存.

You have to pass the parameters to scanf as pointers so it can write into the memory represented by the variable, not the memory represented by the variable value.

scanf("%d%d%d",&x,&y,&z);




附带说明一下,您可能希望在每个%d之间都留有空格,因此您可以输入3个数字作为123 456 789
否则,您必须使用换行符将数字分开,例如




On a side note, you probably want spaces in between each %d so you can enter the 3 numbers as 123 456 789
otherwise you have to separate the numbers by a line break like

123
456
789


这篇关于有关编程的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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