3.2 if控制经典案例代数法交换值
#include<stdio.h>
/* 3.2
author:edcfreedom
date:2021/8/6
funDescription:
if,big,databig,三个数交换
*/
int main()
{
int data1;
int data2;
int data3;
int datatmp;//不管怎么输入数据,data1中的数都为小数
printf("请输入三个数\n");
scanf("%d%d%d",&data1,&data2,&data3);
if(data1>data2){
datatmp = data2;
data2 = data1;
data1 = datatmp;
}
if(data1>data3){
datatmp = data3;
data3 = data1;
data1 = datatmp;
}
if(data2>data3){
datatmp = data3;
data3 = data2;
data2 = datatmp;
}
printf("%d,%d,%d\n",data1,data2,data3);
return 0;
}