还是不明白为什么WA
#include <iostream>
using namespace std;
const int MAXN = 100;
int main()
{
int n,s = 0;
cin >> n;
int a[MAXN];
int d;
cin >> d;
for (int i = n;i >= 1;i--)
{
a[i] = d % 10;
d = d / 10;
}
while (n > 0)
{
n = n - 3;
s++;
}
for (int i = 1;i <= s;i++)
{
if (i != s)
{
cout << a[2 * i - 1] << a[2 * i] << a[2 * i + 1] << "-";
}
else
{
if (n >= 0)
{
cout << a[2 * i] << a[2 * i + 1] << a[2 * i + 2];
}
else
{
cout << a[2 * i] << a[2 * i + 1];
}
}
}
}
我貌似不存在有多大问题啊【困惑脸】