Submission #415211

#TimeUsernameProblemLanguageResultExecution timeMemory
415211GK2007Group Photo (JOI21_ho_t3)C++14
Compilation error
0 ms0 KiB
#include<iostream>
using namespace std;
int main(){
	int n,i,c=0,d=0,e=0;
	cin>>n;
	int a[n+1];
	for(i=1; i<=n; i++)
	{
		cin>>a[i];
	}
	while(c==0)
	{
		d=0
		for(i=1; i<n; i++)
		{
			if(a[i]>=a[i+1]+2)
			{
				swap(a[i], a[i+1]);
				d=1;
				e++;
			}
		}
		if(d==0)
		{
			c=1;
		}
	}
	cout<<e;
	return 0;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:13:6: error: expected ';' before 'for'
   13 |   d=0
      |      ^
      |      ;
   14 |   for(i=1; i<n; i++)
      |   ~~~ 
Main.cpp:14:13: warning: statement has no effect [-Wunused-value]
   14 |   for(i=1; i<n; i++)
      |            ~^~
Main.cpp:14:20: error: expected ';' before ')' token
   14 |   for(i=1; i<n; i++)
      |                    ^
      |                    ;