天梯赛座位分配c++
时间: 2023-12-22 07:28:09 浏览: 128
以下是天梯赛座位分配的C++代码实现:
```c++
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> m(n);
for (int i = 0; i < n; i++) {
cin >> m[i];
}
int cnt = 0;
while (true) {
bool flag = false;
for (int i = 0; i < n; i++) {
if (m[i] > 0) {
cout << i + 1 << "-" << 10 - m[i] % 10 << " ";
m[i]--;
cnt++;
flag = true;
}
}
if (!flag) {
break;
}
}
while (cnt % 10 != 0) {
cout << "0 ";
cnt++;
}
return 0;
}
```
阅读全文