简单的C程序不断崩溃 [英] simple c program keeps crashing

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

问题描述

#include <stdio.h>
int main(void)
{
int a,b,c;
printf("Enter values of a,b,c:");
scanf("%d %d %d",a,b,c);

printf("\nDescending order of the numbers entered:");

/*Test for Biggest Number*/
if((a>b)&&(a>c))
 printf("%d",a);
else if((b>a)&&(b>c))
 printf("%d",b);
else if((c>a)&&(c>b))
 printf("%d",c);

 /*Test for Second Biggest Number*/
 if((a>b&&a<c)||(a<b&&a>c))
  printf("%d",a);
 else if((b>a&&b<c)||(b<a&&b>c))
  printf("%d",b);
 else if((c>a&&c<b)||(c<a&&c>b))
  printf("%d",c);

/*Test for Smallest Number*/
if((a<b)&&(a<c))
 printf("%d",a);
else if((b<a)&&(b<c))
 printf("%d",b);
else if((c<a)&&(c<b))
 printf("%d",c);

 return 0;
}

这是一个ac程序,其中输入了3个数字,并且程序打印出降序。我编译程序并运行程序。输入三个数字后,程序将崩溃。我的代码有问题吗?还是我必须添加一些东西?

this is a c program in which 3 numbers are entered and the program prints the in descending order. i compiled the program and the ran the program.after entering the three numbers the program would just crash. is there something wrong with my code or do i have to add something?

推荐答案

那是因为您没有传递您的地址变量 scanf 。更改

That's because you are not passing the address of your variables to scanf. Change

scanf("%d %d %d",a,b,c) 

scanf("%d %d %d",&a,&b,&c)

这篇关于简单的C程序不断崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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