Usepointertocompletetheassignment.definearrayforthreeintegers.
Writethreefunctions,whichareinput(),deal(),print()
Theinput()functionneedstocompletethreenumber'sinput.
Thedeal()functionneedstoputthesmallestontothefirstposition,putthebiggestoneontotheendofthesequence.
Theprint()functionneedstoprinttheresult.
#include "stdafx.h"
void input(int *a,int *b,int *c);
void deal(int *a,int *b,int *c);
void print(int a,int b,int c);
int main()
{
int a=0,b=0,c=0;
input(&a,&b,&c);
deal(&a,&b,&c);
print(a,b,c);
return 0;
}
void input(int *a,int *b,int *c)
{
printf("输入三个整数:\n");
scanf("%d%d%d",a,b,c);
}
void deal(int *a,int *b,int *c)
{
int t;
if(*a<*b)
{
t=*a;
*a=*b;
*b=t;
}
if(*a<*c)
{
t=*a;
*a=*c;
*c=t;
}
if(*b<*c)
{
t=*b;
*b=*c;
*c=t;
}
}
void print(int a,int b,int c)
{
printf("%d,%d,%d",a,b,c);
}