打卡7.25

作者: 今生何求惟你 | 来源:发表于2018-07-25 22:48 被阅读0次

题目:输入3个数a,b,c,按大小顺序输出。(函数方法)

程序:

#include <stdio.h>

void swap(int *p1,int *p2);

int main(void)

{

int a,b,c;

printf("Please enter three number:\n");

scanf("%d,%d,%d",&a,&b,&c);

printf("The early elements are:%d,%d,%d\n",a,b,c);

if(a > b)  swap(&a,&b);

if(a > c)  swap(&a,&c);

if(b > c)  swap(&b,&c);

printf("The last elements are:%d,%d,%d\n",a,b,c);

    return 0;

}

void swap(int *p1,int *p2)

{

int p;

p = *p1;

*p1 = *p2;

*p2 = p;

}

输出样例

打卡7.25

相关文章

网友评论

    本文标题:打卡7.25

    本文链接:https://www.haomeiwen.com/subject/amammftx.html