公众号【C you again】回复 “浙大版C语言” 查看每道题目详细实现思路
公众号【C you again】回复 “编程交流群” 进C/C++/Java编程题交流、问题解答群
本题要求将输入的任意3个整数从小到大输出。
输入格式:
输入在一行中给出3个整数,其间以空格分隔。
输出格式:
在一行中将3个整数从小到大输出,其间以“->”相连。
输入样例:
4 2 8
输出样例:
2->4->8
代码:
#include<stdio.h>
int main()
{
int arr[3];
scanf("%d %d %d",&arr[0],&arr[1],&arr[2]);
int i;
int index;
int temp;
int j;
for(i=0;i<2;i++)
{
index=i;
temp=arr[i];
for(j=i+1;j<3;j++)
{
if(arr[j]<=arr[index]) index=j;
}
arr[i]=arr[index];
arr[index]=temp;
}
printf("%d->%d->%d
",arr[0],arr[1],arr[2]);
return 0;
}
作者: C you again,从事软件开发 努力在IT搬砖路上的技术小白
公众号:【
C you again】分享计算机类毕业设计源码、IT技术文章、游戏源码、网页模板、程序人生等等。公众号回复 【
粉丝】进博主技术群,与大佬交流,领取干货学习资料
关于转载:欢迎大家转载本文,转载时表明出处
求赞环节:创作不易,记得
点赞+
评论+
转发
,谢谢你一路支持