Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
109061 陈铎文 22插入数据 C++ Presentation Error 3 MS 272 KB 628 2025-01-25 10:52:44

Tests(0/10):


Code:

#include <iostream> #include <algorithm> int main() { const int MAX_SIZE = 100; int n, a[MAX_SIZE]; std::cin >> n; if (n <= 0 || n > MAX_SIZE) { std::cout<< std::endl; return 1; } for (int i = 0; i < n; i++) { std::cin >> a[i]; } for (int i = 0; i < n; i++) { for (int j = 0; j < n - i - 1; j++) { if (a[j] < a[j + 1]) { std::swap(a[j], a[j + 1]); } } } std::cout << std::endl; for (int i = 0; i < n; i++) { std::cout << a[i] << std::endl; } return 0; }