从小到大输出四个整数(C语言)

一、N-S流程图;

二、运行结果;

三、源代码;

cs 复制代码
# define _CRT_SECURE_NO_WARNINGS
# include <stdio.h>

int main()
{
	//初始化变量值;
	int a, b, c, d;
	int t = 0;

	//提示用户;
	printf("请输入四个整数a b c d:");
	//获取用户输入的值;
	scanf("%d %d %d %d", &a, &b, &c, &d);

	//比较运算;
	if (a > b)
	{
		//交换位置;
		t = a;
		a = b;
		b = t;
	}

	if (a > c)
	{
		//交换位置;
		t = a;
		a = c;
		c = t;
	}

	if (a > d)
	{
		//交换位置;
		t = a;
		a = d;
		d = t;
	}

	if (b > c)
	{
		//交换位置;
		t = b;
		b = c;
		c = t;
	}

	if (b > d)
	{
		//交换位置;
		t = b;
		b = d;
		d = t;
	}

	if (c > d)
	{
		//交换位置;
		t = c;
		c = d;
		d = t;
	}

	//输出结果;
	printf("根据您输入的数据,我们从小到大排序得到结果为:%d<%d<%d<%d", a, b, c, d);

	return 0;
}
相关推荐
万粉变现经纪人3 小时前
如何解决 pip install -r requirements.txt 私有索引未设为 trusted-host 导致拒绝 问题
开发语言·python·scrapy·flask·beautifulsoup·pandas·pip
qq_479875433 小时前
C++ std::Set<std::pair>
开发语言·c++
云知谷5 小时前
【C++基本功】C++适合做什么,哪些领域适合哪些领域不适合?
c语言·开发语言·c++·人工智能·团队开发
l1t6 小时前
DeepSeek辅助利用搬移底层xml实现快速编辑xlsx文件的python程序
xml·开发语言·python·xlsx
C_Liu_8 小时前
C++:list
开发语言·c++
my rainy days8 小时前
C++:友元
开发语言·c++·算法
小梁努力敲代码8 小时前
java数据结构--List的介绍
java·开发语言·数据结构
云知谷8 小时前
【HTML】网络数据是如何渲染成HTML网页页面显示的
开发语言·网络·计算机网络·html
lly2024069 小时前
SQL ROUND() 函数详解
开发语言