解题思路:
注意事项:
参考代码:
#include<iostream>
#include<string>
using namespace std;
void outout(int a[])
{
for (int i = 0; i < 10; i++)
{
cout << a[i] << " ";
}
}
void myswap(int a[])
{
int first = 0;
int end = 9;
int max = a[0];
int temp = 0;
int temp1 = 0;
int min = a[0];
for (int i = 1; i < 10; i++)
{
if (a[i] > max)
{
max=a[i] ;
temp = i;
}
}
for (int i = 1; i < 10; i++)
{
if (a[i] < min)
{
min=a[i];
temp1 = i;
}
}
int t2 = a[temp];
a[temp] = a[end];
a[end] = t2;
int t1 = a[temp1];
a[temp1] = a[first];
a[first] = t1;
}
void input(int a[])
{
for (int i = 0; i < 10; i++)
{
cin >> a[i];
}
}
int main()
{
int a[20] = {0};
input(a);
myswap(a);
outout(a);
system("pause");
}
0.0分
0 人评分
震宇大神的杀毒软件 (C++代码)浏览:1117 |
C二级辅导-公约公倍 (C语言代码)浏览:1510 |
简单的a+b (C语言代码)浏览:544 |
兰顿蚂蚁 (C++代码)浏览:1091 |
多输入输出练习1 (C语言代码)浏览:1187 |
拆分位数 (C语言代码)浏览:1328 |
不会做的浏览:874 |
C语言程序设计教程(第三版)课后习题6.10 (C语言代码)浏览:880 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:473 |
Cylinder (C语言描述+详细分析)浏览:3265 |