Use pointer to complete the assignment. define array for three integers.
Write three functions, which are input(), deal(), print()
The input() function needs to complete three number's input.
The deal() function needs to put the smallest onto the first position, put the biggest one onto the end of the sequence.
The print() function needs to print the result.
#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
{
t=*a;
*a=*b;
*b=t;
}
if(*a
{
t=*a;
*a=*c;
*c=t;
}
if(*b
{
t=*b;
*b=*c;
*c=t;
}
}
void print(int a,int b,int c)
{
printf("%d,%d,%d",a,b,c);
}