#include<bits/stdc++.h> using namespace std; int main(){ vector<int> a(10,0),b(10,0); int x; for(int i=0;i<10;i++){ cin >> x; a[i] = x; } for(int i=0;i<10;i++){//把负的变成正的保存在另一个向量里 if(a[i]<0){ b[i] = -a[i]; } else{ b[i] = a[i]; } } int temp = min_element(b.begin(),b.end())-b.begin();//保存绝对值最大数的下标 swap(a[temp],a[9]); for(int i=0;i<10;i++){ if(i==9){ cout << a[i] << endl; } else{ cout << a[i] << " "; } } return 0; }
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题1.6 (C++代码)浏览:907 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:548 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:569 |
1908题解浏览:677 |
1011题解浏览:810 |
C语言程序设计教程(第三版)课后习题9.10 (C语言代码)浏览:859 |
模拟计算器 (C++代码)浏览:881 |
C二级辅导-等差数列 (C语言代码)浏览:795 |
2006年春浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:722 |
前10名 (C语言代码)浏览:770 |