希望更丰富的展现?使用Markdown
by 痴痴的秋叶 @ 2019-01-13 16:30:28
希望更丰富的展现?使用[InternetShortcut]
URL=https://www.luogu.org/wiki/show?name=������markdown
[InternetShortcut.A]
URL=https://www.luogu.org/wiki/show?name=������markdown
[InternetShortcut.W]
URL=https://www.luogu.org/wiki/show?name+AD1eLlKp/xo-markdown
by t162 @ 2019-01-13 16:38:24
先帮你改一下格式的问题先
```cpp
include<iostream>
using namespace std;
const int N=100;
int main()
{
int n,a[N],g;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
if(a[j]<a[i]){g++;cout<<g;}
else continue;
}
cout<<g<<" ";
}
return 0;
}
```
by NKL丶 @ 2019-01-13 16:49:02
你每一次比较时都输出了一次g……(话说你应该知道的呀……)
by NKL丶 @ 2019-01-13 16:49:46
格式修正
```C++
#include <iostream>
using namespace std;
const int N = 100;
int main() {
int n, a[N], g;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= i; j++) {
if (a[j] < a[i]) {
g++;
cout << g;
}
else continue;
}
cout << g << " ";
}
return 0;
}
```
好多了。
错因分析:
1. 在代码第`14`行中:
反复输出了g,进入`if (a[j] < a[i])`时反复输出g的值导致Wrong Answer;
by NetherDevil @ 2019-05-05 21:09:03