标签:图片 mes 数据 amp iostream pre std names ios
数据的交换输出
题目分析:
找到最小值,然后与第一个换位置
代码:
#include<iostream> using namespace std; int main() { int n; int a[101]; while (cin >> n&&n) { int i,t, min = 99999; int num = 0; for (i = 0; i < n; i++) { cin >> a[i]; } for (i = 0; i < n; i++) { if (min>a[i]) { num = i; min = a[i]; } } t = a[0]; a[0] = min; a[num] = t; for (i = 0; i<n; i++) { if (i != 0) printf(" "); printf("%d", a[i]); } printf("\n"); } system("pause"); return 0; }
标签:图片 mes 数据 amp iostream pre std names ios
原文地址:https://www.cnblogs.com/pcdl/p/12275375.html