可能我还很差


私信TA

用户名:dotcpp0606413

访问量:154

签 名:

努力跟着大佬们学习,加油!

等  级
排  名 3911
经  验 1734
参赛次数 0
文章发表 10
年  龄 0
在职情况 学生
学  校 中国计量大学
专  业

  自我简介:

一个不敬业的研究生,研究光谱,却整天想着敲代码!

解题思路:

注意事项:

参考代码:

#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 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区