输入10个整数
来源:互联网 发布:iphone4s支持3g网络吗 编辑:程序博客网 时间:2024/05/16 09:42
Description
输入10个整数,将其中最小的数与第一个数对换,把最大的数与最后一个数对换。写三个函数;①输入10个数;②进行处理;③输出10个数。
Input
10个整数
Output
整理后的十个数,每个数后跟一个空格(注意最后一个数后也有空格)
Sample Input
2 1 3 4 5 6 7 8 10 9
Sample Output
1 2 3 4 5 6 7 8 9 10
HINT
主函数已给定如下,提交时不需要包含下述主函数
/* C/C++代码 */
int main()
{
const int n=10;
int a[n];
input(a,n);
handle(a,n);
output(a,n);
return 0;
}
#include <iostream>using namespace std;void input(int *b,int n);void handle(int *c,int n);void output(int *d,int n);int main(){const int n=10;int a[n];input(a,n);handle(a,n);output(a,n);return 0;}void input(int *b,int n){int i;for(i=0;i<n;i++)cin>>b[i];}void handle(int *c,int n){int t,*min,*max,*i,m;min=max=c;m=*max;for(i=c;i<(c+n);i++){if(*max<*i)max=i;else if(*min>*i)min=i;}t=*min;*min=c[0];c[0]=t;if(*max==c[0])max=min;t=*max;*max=c[9];c[9]=t;}void output(int *d,int n){int *m=d;for(m=d;m<(d+n);m++)cout<<*m<<' ';}
0 0
- 输入10个整数
- 输入10个整数
- acm-数组初步,输入10个整数,逆序输出
- 第九周项目5 输入10个整数,找出最大值
- OJ刷题之《输入10个整数》
- 从键盘输入10个整数求和,输入0结束
- 输入20个整数并求和
- C#- 多个整数的输入
- 输入3个整数,输出其最大值
- 输入5个整数按照大小排序
- 输入5个整数的异常处理
- 从命令行输入5个整数
- 接收用户输入的10个整数,将这10个整数按从大到小顺寻输出,注意nextInt()方法
- C语言1.用选择法对10个整数排序。10个整数用scanf函数输入。
- 输入多个整数组成最大多位整数
- 输入15个整数,并检查10是否包含其中,若是,它是第几个被输入的
- 输入n个整数,输出其中最小的k个
- 输入n个整数,输出其中最小的k个
- 【Linux学习】pthread_create主线程与创建的新线程之间退出关系
- B. Domino Effect
- 函数getimagesize获得图片的长宽等信息
- Window下Django的安装及配置
- 利用Selenium自动化测试android wap页
- 输入10个整数
- 使用JDBC时Class.forName()的作用
- 调试是开发的基础
- HTTP协议详解
- 设置CoreData显示sql语句
- Python使用struct处理二进制
- 自动运行php文件
- 输入n个数和输出调整后的n个数
- Mac 下Andriod 开发环境搭建