This is a short essay

Time:2021-2-27
The little fish is more lovely than the little fish
 

describe

People are more angry than people; fish are more difficult to die than fish. Xiaoyu recently took part in a “loveliness contest” to compare the loveliness of each fish. The fish in the competition are arranged in a row from left to right, with their heads facing to the left. Then each fish will get an integer value, which indicates the loveliness of the fish. Obviously, the bigger the integer, the more loveable the fish is. Moreover, the loveliness of any two fish may be the same. Since all the fish heads are facing to the left, each fish can only see the loveliness of the fish on its left. They are calculating in their hearts how many fish are not as loveable as themselves within their eyesight. Please help these lovely but fish brain is not enough to calculate.

 

input

In the first line, enter an integer n to represent the number of fish.

In the second line, enter n integers, separated by spaces, to show the loveliness of each fish from left to right.

 

output

Output n integers in one line, separated by spaces, indicating in turn how many fish in each small fish’s eyes are not as cute as themselves.

 

Input sample 1

6
4 3 0 5 1 2

Output sample 1

0 0 0 3 1 2


My solution to this problem is to use double circulation.
Define an array and initialize it to zero. Each time you enter a number, you will cycle to judge how many fish are uglier than you.


code:
1 #include
 2 #include
 3 using namespace std;
 4 int main()
 5 {
 6     int n;
 7     cin>>n;
 8     int a[n+1],s[n+1]={0};
 9     for(int i=1;i<=n;i++)
10     {
11         cin>>a[i];
12         for(int j=1;j

 



Recommended Today

Practice analysis of rust built-in trait: partialeq and EQ

Abstract:Rust uses traits in many places, from simple operator overloading to subtle features like send and sync. This article is shared from Huawei cloud community《Analysis of rust built-in trait: partialeq and EQ》Author: debugzhang Rust uses traits in many places, from simple operator overloading to subtle features like send and sync. Some traits can be automatically […]