从键盘输入3个整数,按照从大到小的顺序输出。(用两个函数完成。)
从键盘输入3个整数,按照从大到小的顺序输出。(两个函数完成。)
#include <stdio.h> #include <stdlib.h> void My_printf_scanf(void); void sort_val(int * a, int * b, int * c); int main ( void ) { My_printf_scanf(); system("pause"); return 0; } void My_printf_scanf(void) { int a, b, c; printf("please you input tne first number:"); scanf("%d", &a); printf("please you input tne second number:"); scanf("%d", &b); printf("please you input tne third number:"); scanf("%d", &c); sort_val(&a, &b, &c); } void sort_val(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; } printf("The sort is %d, %d, %d.\n", *a, *b, *c); }
[此贴子已经被作者于2019-5-28 22:39编辑过]