C 练习实例66

C 语言教程 · 2019-02-22 10:26:30

题目:输入3个数a,b,c,按大小顺序输出。

程序分析:利用指针方法。

实例

// Created by www.codercto.com on 15/11/9. // Copyright © 2015年 码农教程. All rights reserved. // # include<stdio.h> void swap(int *, int *); int main(void) { int a, b, c; int *p1, *p2, *p3; printf("输入 a, b ,c:\n"); scanf("%d %d %d", &a, &b, &c); p1 = &a; p2 = &b; p3 = &c; if(a>b) swap(p1, p2); if(a>c) swap(p1, p3); if(b>c) swap(p2, p3); printf("%d %d %d\n", a, b, c); } void swap(int *s1, int *s2) { int t; t = *s1; *s1 = *s2; *s2 = t; }

以上程序执行输出结果为:

输入 a, b ,c:
1 3 2
1 2 3

点击查看所有 C 语言教程 文章: https://codercto.com/courses/l/17.html

查看所有标签

Software Engineering for Internet Applications

Software Engineering for Internet Applications

Eve Andersson、Philip Greenspun、Andrew Grumet / The MIT Press / 2006-03-06 / USD 35.00

After completing this self-contained course on server-based Internet applications software, students who start with only the knowledge of how to write and debug a computer program will have learned ho......一起来看看 《Software Engineering for Internet Applications》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具