criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include<stdio.h>
using namespace std;

int bubbleSort(int A[],int N){
	int sw = 0;
	bool flag = 1;
	
	for(int i = 0; flag; i++){
		flag = 0;
		for(int j = N -1; j >= i + 1;j--){
			if(A[j] < A[j-1]){
				swap(A[j] < A[j - 1]);
				flag = 1;
				sw++;
			}
		}
	}
	return sw
}

int main(){
	int A[100],N,sw;
	cin >> N;
	for(int i=0;i<N;i++) cin >> A[i];
	
	sw = bubbleSort(A,N);
	
	for(int i=0;i<N;i++){
		if(i) cout << " ";
		cout << A[i];
	}
	cout << endl;
	cout << sw << endl;
	
	return 0;
}


Compiler output:
a.cc: In function 'int bubbleSort(int*, int)':
a.cc:12:33: error: 'swap' was not declared in this scope; did you mean 'sw'?
   12 |                                 swap(A[j] < A[j - 1]);
      |                                 ^~~~
      |                                 sw
a.cc:18:18: error: expected ';' before '}' token
   18 |         return sw
      |                  ^
      |                  ;
   19 | }
      | ~                 
a.cc: In function 'int main()':
a.cc:23:9: error: 'cin' was not declared in this scope
   23 |         cin >> N;
      |         ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    1 | #include<stdio.h>
  +++ |+#include <iostream>
    2 | using namespace std;
a.cc:29:23: error: 'cout' was not declared in this scope
   29 |                 if(i) cout << " ";
      |                       ^~~~
a.cc:29:23: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:30:17: error: 'cout' was not declared in this scope
   30 |                 cout << A[i];
      |                 ^~~~
a.cc:30:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:32:9: error: 'cout' was not declared in this scope
   32 |         cout << endl;
      |         ^~~~
a.cc:32:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:32:17: error: 'endl' was not declared in this scope
   32 |         cout << endl;
      |                 ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    1 | #include<stdio.h>
  +++ |+#include <ostream>
    2 | using namespace std;
Language: C++

#include<iostream>
#include<cstdio>
//バブルソート　in:配列、要素数 out:ソート回数
int bubble_sort(int *A,int N){ 
    int sw=0;
    int i,j;
    bool flag=1;
        
    for(i=0;flag;i++){
        flag=0;
        for(j=N;j>=i+1;j--){                               
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                flag=1;
                sw++;
            }                    
        }   
    }   
    return sw; 
}

int main(void){
    int A[100],i,j,N,sw;

    scanf("%d",&N);
    for(i=0;i<N;i++)
        scanf("%d",&A[i]);

    sw=bubble_sort(A,N);

    for(i=0;i<N;i++){
        if(i)
            putchar(' ');
        printf("%d",A[i]);
    }   
    putchar('\n');
    printf("%d",sw);
   
   return 0;
}



Compiler output:
a.cc: In function 'int bubble_sort(int*, int)':
a.cc:13:17: error: 'swap' was not declared in this scope
   13 |                 swap(A[j],A[j-1]);
      |                 ^~~~
a.cc:13:17: note: suggested alternatives:
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/string:68,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/tuple:2823:5: note:   'std::swap'
 2823 |     swap(tuple<_Elements...>&, tuple<_Elements...>&) = delete;
      |     ^~~~
In file included from /usr/include/c++/14/bits/exception_ptr.h:41,
                 from /usr/include/c++/14/exception:166,
                 from /usr/include/c++/14/ios:41:
/usr/include/c++/14/bits/move.h:226:5: note:   'std::swap'
  226 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/14/bits/move.h:226:5: note:   'std::swap'
/usr/include/c++/14/bits/exception_ptr.h:229:5: note:   'std::__exception_ptr::swap'
  229 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
Language: C++

#include<iostream>
#include<cstdio>
using namespace std;
//バブルソート　in:配列、要素数 out:ソート回数
int bubble_sort(int *A,int N){
    int sw=0;
    int i,j;
    bool flag=1;

    for(i=0;flag;i++){
        flag=0;
        for(j=N;j>=i+1;j--){
            if(A[j]<A[j-1]){
                swap(A[j],A[j-1]);
                flag=1;
                sw++;
            }                
        }
    }
    return sw;
}

int main(void){
    int A[100],i,j,N,sw;

    scanf("%d",&N);
    for(i=0;i<N;i++)
        scanf("%d",&A[i]);

    sw=bubble_sort(A,N);

    for(i=0;i<N;i++){
        if(i)
            putchar(' ');
        printf("%d",A[i]);
    }
    putchar('\n');
    printf("%d\n",sw);                                     

    return 0;



Compiler output:
a.cc: In function 'int main()':
a.cc:40:14: error: expected '}' at end of input
   40 |     return 0;
      |              ^
a.cc:23:15: note: to match this '{'
   23 | int main(void){
      |               ^
Language: C++

#include <stdio.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repi(i, n, a) for(int i = a; i < n; ++i)

int main(void) {
  int n, i, j, ans = 0;
  scanf("%d", &n);
  int a[n];
  rep(i, n) scanf("%d", &a[i]);
  int flag = 0;
  while(flag) for(j = n - 1; j > 0; --j) if(a[j] < a[j - 1]) {
    int t = a[j], a[j] = a[j - 1], a[j - 1] = t;
    flag = 1;
    ++ans;
  }
  rep(i, n) {
    if(i) printf(" %d", a[i]);
    else printf("%d", a[i]);
  }
  printf("\n%d\n", ans);
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:33: error: array must be initialized with a brace-enclosed initializer
   12 |     int t = a[j], a[j] = a[j - 1], a[j - 1] = t;
      |                          ~~~~~~~^
a.cc:12:36: error: conflicting declaration 'int a [(j + -1)]'
   12 |     int t = a[j], a[j] = a[j - 1], a[j - 1] = t;
      |                                    ^
a.cc:12:19: note: previous declaration as 'int a [j]'
   12 |     int t = a[j], a[j] = a[j - 1], a[j - 1] = t;
      |                   ^
Language: C++

#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int *A = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	int c = 0,temp;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			if (A[i] > A[j]) {
				temp = A[i];
				A[i] = A[j];
				A[j] = temp;
				++c;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << A[i];
		if (i != n - 1)
			cout << ' ';
		else
			cout << endl;
	}
	cout << c << endl;
	delete[] A;


Compiler output:
a.cc: In function 'int main()':
a.cc:29:20: error: expected '}' at end of input
   29 |         delete[] A;
      |                    ^
a.cc:3:12: note: to match this '{'
    3 | int main() {
      |            ^
Language: C++

#include <iostream>
using namespace std;

void trace(int A[], int n)
{
    for (int i = 0; i < n; i++)
    {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}


int main()
{
    int maxN = 1000;
    int A[maxN];

    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    //bubble sort
    int swp = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = N-1; j >= i+1; j--)
        {
            if (A[j] < A[j-1])
            {
                int tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                swp++；
        }
    }
    
    trace(A,N);
    cout << swp << endl;
  
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:22: error: expected ';' before '\U0000ff1b'
   38 |                 swp++；
      |                      ^~
      |                      ;
a.cc:46:2: error: expected '}' at end of input
   46 | }
      |  ^
a.cc:16:1: note: to match this '{'
   16 | {
      | ^
Language: C++

#include <iostream>
using namespace std;

void trace(int A[], int n)
{
    for (int i = 0; i < n; i++)
    {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}


int main()
{
    int maxN = 1000;
    int A[maxN];

    int N;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    //bubble sort
    int swp = 0;
    for (int i = 0; i < N; i++)
    {
        for (int j = N-1; j >= i+1; j--)
        {
            if (A[j] < A[j-1])
            {
                int tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                swp++;
        }
    }
    
    trace(A,N);
    cout << swp << endl;
  
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:46:2: error: expected '}' at end of input
   46 | }
      |  ^
a.cc:16:1: note: to match this '{'
   16 | {
      | ^
Language: C++

#include <stdio.h>
#include <iostream>

using namespace std;

void bubbleprint(int A[], int N,int replace)
{
	for (int i = 0; i < N; i++)
	{
		if (i > 0)
		{
			printf(" ");
		}

		printf("%d", A[i]);
	}
	printf("\r\n");
	printf("%d", replace);
}

void bubbleSort(int A[], int N)
{
	int flg = 1;
	int replace=0;

	while (flg)
	{
		flg = 0;
		for (int i = N-1; i>0; i--)
		{
			if (A[i] < A[i - 1]) 
			{
				swap(A[i],A[i - 1]);
				replace++;
				flg = 1;
			}
		}
	}

	bubbleprint(A,N,replace);
}

int main()
{
	int N, A[100];

	scanf("%d", &N);

	for (int i = 0; i < N; i++)
	{
		scanf("%d", &A[i]);
	}
	bubbleSort(A, N);

	return 0;


Compiler output:
a.cc: In function 'int main()':
a.cc:55:18: error: expected '}' at end of input
   55 |         return 0;
      |                  ^
a.cc:44:1: note: to match this '{'
   44 | {
      | ^
Language: C++

#include<stdio.h>
#include<stdlib.h>

int bubblesort(int a[],int n){
  int i,j,tmp,count;
  for(i=0; i<n-1; i++){
    for(j=n-1; j>i; j--){
      if(a[j]<a[j-1]){
      tmp = a[j];
      a[j] = a[j-1];
      a[j-1] = tmp;
      count++;
      }
    }
  }
  return count;
}



int main(){
  int num,i,result;
  int *A;
  scanf("%d",&num);

  A = calloc(num,sizeof(int));

  for(i=0; i<num; i++){
    scanf("%d",&A[i]);
  }

  result = bubblesort(A,num);

  for(i=0; i<num; i++){
    printf("%d ",A[i]);
  }
  puts("");
  printf("%d\n",result);

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:13: error: invalid conversion from 'void*' to 'int*' [-fpermissive]
   26 |   A = calloc(num,sizeof(int));
      |       ~~~~~~^~~~~~~~~~~~~~~~~
      |             |
      |             void*
Language: C++

#include <iostream>
#include <algorithm>
using namespace std;

int bubble_sort(int *data, int n)
{
	int flag = 1;
	int count = 0;
	int i = 0;
	while(flag) {
		flag = 0;
		for(int j = n-1; j > i; j--) {
			if(data[j] < data[j-1]) {
				swap(data[j], data[j-1]);
				flag = 1;
				count++;
			}
		}
		i++;
	}
	return count;
}

int main(void)
{
	int *data;
	int n;
	cin >> n;

	data = new int[n];
	for(int i = 0; i < n; i++) {
		cin >> data[i];
	}

	int change = bubble_sort(data, n);

	for(int i = 0; i < n; i++) {
		if(i != 0) cout << ' ';
		cout << data[i];
	}
	cout << endl;
	cout << change << endl;

	delete data;	
	return 0;
}#include <iostream>
#include <algorithm>
using namespace std;

int bubble_sort(int *data, int n)
{
	int flag = 1;
	int count = 0;
	int i = 0;
	while(flag) {
		flag = 0;
		for(int j = n-1; j > i; j--) {
			if(data[j] < data[j-1]) {
				swap(data[j], data[j-1]);
				flag = 1;
				count++;
			}
		}
		i++;
	}
	return count;
}

int main(void)
{
	int *data;
	int n;
	cin >> n;

	data = new int[n];
	for(int i = 0; i < n; i++) {
		cin >> data[i];
	}

	int change = bubble_sort(data, n);

	for(int i = 0; i < n; i++) {
		if(i != 0) cout << ' ';
		cout << data[i];
	}
	cout << endl;
	cout << change << endl;

	delete data;	
	return 0;
}#include <iostream>
#include <algorithm>
using namespace std;

int bubble_sort(int *data, int n)
{
	int flag = 1;
	int count = 0;
	int i = 0;
	while(flag) {
		flag = 0;
		for(int j = n-1; j > i; j--) {
			if(data[j] < data[j-1]) {
				swap(data[j], data[j-1]);
				flag = 1;
				count++;
			}
		}
		i++;
	}
	return count;
}

int main(void)
{
	int *data;
	int n;
	cin >> n;

	data = new int[n];
	for(int i = 0; i < n; i++) {
		cin >> data[i];
	}

	int change = bubble_sort(data, n);

	for(int i = 0; i < n; i++) {
		if(i != 0) cout << ' ';
		cout << data[i];
	}
	cout << endl;
	cout << change << endl;

	delete data;	
	return 0;
}


Compiler output:
a.cc:46:2: error: stray '#' in program
   46 | }#include <iostream>
      |  ^
a.cc:91:2: error: stray '#' in program
   91 | }#include <iostream>
      |  ^
a.cc:46:3: error: 'include' does not name a type
   46 | }#include <iostream>
      |   ^~~~~~~
a.cc:50:5: error: redefinition of 'int bubble_sort(int*, int)'
   50 | int bubble_sort(int *data, int n)
      |     ^~~~~~~~~~~
a.cc:5:5: note: 'int bubble_sort(int*, int)' previously defined here
    5 | int bubble_sort(int *data, int n)
      |     ^~~~~~~~~~~
a.cc:69:5: error: redefinition of 'int main()'
   69 | int main(void)
      |     ^~~~
a.cc:24:5: note: 'int main()' previously defined here
   24 | int main(void)
      |     ^~~~
a.cc:91:3: error: 'include' does not name a type
   91 | }#include <iostream>
      |   ^~~~~~~
a.cc:95:5: error: redefinition of 'int bubble_sort(int*, int)'
   95 | int bubble_sort(int *data, int n)
      |     ^~~~~~~~~~~
a.cc:5:5: note: 'int bubble_sort(int*, int)' previously defined here
    5 | int bubble_sort(int *data, int n)
      |     ^~~~~~~~~~~
a.cc:114:5: error: redefinition of 'int main()'
  114 | int main(void)
      |     ^~~~
a.cc:24:5: note: 'int main()' previously defined here
   24 | int main(void)
      |     ^~~~
Language: C++

#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int bubble_sort(int *data, int n)
{
	int flag = 1;
	int count = 0;
	int i = 0;
	while(flag) {
		flag = 0;
		for(int j = n-1; j > i; j--) {
			if(data[j] < data[j-1]) {
				swap(data[j], data[j-1]);
				flag = 1;
				count++;
			}
		}
		i++;
	}
	return count;
}

int main(void)
{
	int *data;
	int n;
	cin >> n;

	data = new int[n];
	for(int i = 0; i < n; i++) {
		cin >> data[i];
	}

	int change = bubble_sort(data, n);

	for(int i = 0; i < n; i++) {
		if(i != 0) cout << ' ';
		cout << data[i];
	}
	cout << endl;
	cout << change << endl;

	delete data;	
	return 0;
}#include <iostream>
#include <algorithm>
using namespace std;

int bubble_sort(int *data, int n)
{
	int flag = 1;
	int count = 0;
	int i = 0;
	while(flag) {
		flag = 0;
		for(int j = n-1; j > i; j--) {
			if(data[j] < data[j-1]) {
				swap(data[j], data[j-1]);
				flag = 1;
				count++;
			}
		}
		i++;
	}
	return count;
}

int main(void)
{
	int *data;
	int n;
	cin >> n;

	data = new int[n];
	for(int i = 0; i < n; i++) {
		cin >> data[i];
	}

	int change = bubble_sort(data, n);

	for(int i = 0; i < n; i++) {
		if(i != 0) cout << ' ';
		cout << data[i];
	}
	cout << endl;
	cout << change << endl;

	delete data;	
	return 0;
}#include <iostream>
#include <algorithm>
using namespace std;

int bubble_sort(int *data, int n)
{
	int flag = 1;
	int count = 0;
	int i = 0;
	while(flag) {
		flag = 0;
		for(int j = n-1; j > i; j--) {
			if(data[j] < data[j-1]) {
				swap(data[j], data[j-1]);
				flag = 1;
				count++;
			}
		}
		i++;
	}
	return count;
}

int main(void)
{
	int *data;
	int n;
	cin >> n;

	data = new int[n];
	for(int i = 0; i < n; i++) {
		cin >> data[i];
	}

	int change = bubble_sort(data, n);

	for(int i = 0; i < n; i++) {
		if(i != 0) cout << ' ';
		cout << data[i];
	}
	cout << endl;
	cout << change << endl;

	delete data;	
	return 0;
}


Compiler output:
a.cc:47:2: error: stray '#' in program
   47 | }#include <iostream>
      |  ^
a.cc:92:2: error: stray '#' in program
   92 | }#include <iostream>
      |  ^
a.cc:47:3: error: 'include' does not name a type
   47 | }#include <iostream>
      |   ^~~~~~~
a.cc:51:5: error: redefinition of 'int bubble_sort(int*, int)'
   51 | int bubble_sort(int *data, int n)
      |     ^~~~~~~~~~~
a.cc:6:5: note: 'int bubble_sort(int*, int)' previously defined here
    6 | int bubble_sort(int *data, int n)
      |     ^~~~~~~~~~~
a.cc:70:5: error: redefinition of 'int main()'
   70 | int main(void)
      |     ^~~~
a.cc:25:5: note: 'int main()' previously defined here
   25 | int main(void)
      |     ^~~~
a.cc:92:3: error: 'include' does not name a type
   92 | }#include <iostream>
      |   ^~~~~~~
a.cc:96:5: error: redefinition of 'int bubble_sort(int*, int)'
   96 | int bubble_sort(int *data, int n)
      |     ^~~~~~~~~~~
a.cc:6:5: note: 'int bubble_sort(int*, int)' previously defined here
    6 | int bubble_sort(int *data, int n)
      |     ^~~~~~~~~~~
a.cc:115:5: error: redefinition of 'int main()'
  115 | int main(void)
      |     ^~~~
a.cc:25:5: note: 'int main()' previously defined here
   25 | int main(void)
      |     ^~~~
Language: C++

##include<iostream>
using namespace std;

int bubbleSort(int A[], int N) {
  int sw = 0
  int flag = 1;
  while flag {
    flag = 0;
    for ( int j = N - 1; 0 < j; j--) {
      if (A[j] < A[j-1]) {
        swap(A[j-1], A[j]);
        sw++; 
        flag = 1;
      }
  return sw;
}

int main() {
  int A[100], N, sw;
  cin >> N;
  for ( int i = 0; i < N; i++ ) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;

  return 0;
}


Compiler output:
a.cc:1:1: error: stray '##' in program
    1 | ##include<iostream>
      | ^~
a.cc:1:3: error: 'include' does not name a type
    1 | ##include<iostream>
      |   ^~~~~~~
a.cc: In function 'int bubbleSort(int*, int)':
a.cc:6:3: error: expected ',' or ';' before 'int'
    6 |   int flag = 1;
      |   ^~~
a.cc:7:9: error: expected '(' before 'flag'
    7 |   while flag {
      |         ^~~~
      |         (
a.cc:7:9: error: 'flag' was not declared in this scope
    7 |   while flag {
      |         ^~~~
a.cc:7:13: error: expected ')' before '{' token
    7 |   while flag {
      |         ~~~~^~
      |             )
a.cc:11:9: error: 'swap' was not declared in this scope; did you mean 'sw'?
   11 |         swap(A[j-1], A[j]);
      |         ^~~~
      |         sw
a.cc:18:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   18 | int main() {
      |         ^~
a.cc:18:9: note: remove parentheses to default-initialize a variable
   18 | int main() {
      |         ^~
      |         --
a.cc:18:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:18:12: error: a function-definition is not allowed here before '{' token
   18 | int main() {
      |            ^
a.cc:29:2: error: expected '}' at end of input
   29 | }
      |  ^
a.cc:7:14: note: to match this '{'
    7 |   while flag {
      |              ^
a.cc:29:2: error: expected '}' at end of input
   29 | }
      |  ^
a.cc:4:32: note: to match this '{'
    4 | int bubbleSort(int A[], int N) {
      |                                ^
a.cc:29:2: warning: control reaches end of non-void function [-Wreturn-type]
   29 | }
      |  ^
Language: C++

##include<iostream>
using namespace std;

int bubbleSort(int A[], int N) {
  int sw = 0;
  int flag = 1;
  while flag {
    flag = 0;
    for ( int j = N - 1; 0 < j; j--) {
      if (A[j] < A[j-1]) {
        swap(A[j-1], A[j]);
        sw++; 
        flag = 1;
      }
  return sw;
}

int main() {
  int A[100], N, sw;
  cin >> N;
  for ( int i = 0; i < N; i++ ) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;

  return 0;
}


Compiler output:
a.cc:1:1: error: stray '##' in program
    1 | ##include<iostream>
      | ^~
a.cc:1:3: error: 'include' does not name a type
    1 | ##include<iostream>
      |   ^~~~~~~
a.cc: In function 'int bubbleSort(int*, int)':
a.cc:7:9: error: expected '(' before 'flag'
    7 |   while flag {
      |         ^~~~
      |         (
a.cc:7:13: error: expected ')' before '{' token
    7 |   while flag {
      |         ~~~~^~
      |             )
a.cc:11:9: error: 'swap' was not declared in this scope; did you mean 'sw'?
   11 |         swap(A[j-1], A[j]);
      |         ^~~~
      |         sw
a.cc:18:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   18 | int main() {
      |         ^~
a.cc:18:9: note: remove parentheses to default-initialize a variable
   18 | int main() {
      |         ^~
      |         --
a.cc:18:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:18:12: error: a function-definition is not allowed here before '{' token
   18 | int main() {
      |            ^
a.cc:29:2: error: expected '}' at end of input
   29 | }
      |  ^
a.cc:7:14: note: to match this '{'
    7 |   while flag {
      |              ^
a.cc:29:2: error: expected '}' at end of input
   29 | }
      |  ^
a.cc:4:32: note: to match this '{'
    4 | int bubbleSort(int A[], int N) {
      |                                ^
a.cc:29:2: warning: control reaches end of non-void function [-Wreturn-type]
   29 | }
      |  ^
Language: C++

##include<iostream>
using namespace std;

int bubbleSort(int A[], int N) {
  int sw = 0;
  int flag = 1;
  while flag {
    flag = 0;
    for ( int j = N - 1; 0 < j; j--) {
      if (A[j] < A[j-1]) {
        swap(A[j-1], A[j]);
        sw++; 
        flag = 1;
      }
  }
  return sw;
}

int main() {
  int A[100], N, sw;
  cin >> N;
  for ( int i = 0; i < N; i++ ) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;

  return 0;
}


Compiler output:
a.cc:1:1: error: stray '##' in program
    1 | ##include<iostream>
      | ^~
a.cc:1:3: error: 'include' does not name a type
    1 | ##include<iostream>
      |   ^~~~~~~
a.cc: In function 'int bubbleSort(int*, int)':
a.cc:7:9: error: expected '(' before 'flag'
    7 |   while flag {
      |         ^~~~
      |         (
a.cc:7:13: error: expected ')' before '{' token
    7 |   while flag {
      |         ~~~~^~
      |             )
a.cc:11:9: error: 'swap' was not declared in this scope; did you mean 'sw'?
   11 |         swap(A[j-1], A[j]);
      |         ^~~~
      |         sw
a.cc:19:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   19 | int main() {
      |         ^~
a.cc:19:9: note: remove parentheses to default-initialize a variable
   19 | int main() {
      |         ^~
      |         --
a.cc:19:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:19:12: error: a function-definition is not allowed here before '{' token
   19 | int main() {
      |            ^
a.cc:30:2: error: expected '}' at end of input
   30 | }
      |  ^
a.cc:4:32: note: to match this '{'
    4 | int bubbleSort(int A[], int N) {
      |                                ^
a.cc:30:2: warning: control reaches end of non-void function [-Wreturn-type]
   30 | }
      |  ^
Language: C++

#include<iostream>
using namespace std;

int bubbleSort(int A[], int N) {
  int sw = 0;
  int flag = 1;
  while flag {
    flag = 0;
    for ( int j = N - 1; 0 < j; j--) {
      if (A[j] < A[j-1]) {
        swap(A[j-1], A[j]);
        sw++; 
        flag = 1;
      }
  }
  return sw;
}

int main() {
  int A[100], N, sw;
  cin >> N;
  for ( int i = 0; i < N; i++ ) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int bubbleSort(int*, int)':
a.cc:7:9: error: expected '(' before 'flag'
    7 |   while flag {
      |         ^~~~
      |         (
a.cc:7:13: error: expected ')' before '{' token
    7 |   while flag {
      |         ~~~~^~
      |             )
a.cc:19:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   19 | int main() {
      |         ^~
a.cc:19:9: note: remove parentheses to default-initialize a variable
   19 | int main() {
      |         ^~
      |         --
a.cc:19:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:19:12: error: a function-definition is not allowed here before '{' token
   19 | int main() {
      |            ^
a.cc:30:2: error: expected '}' at end of input
   30 | }
      |  ^
a.cc:4:32: note: to match this '{'
    4 | int bubbleSort(int A[], int N) {
      |                                ^
a.cc:30:2: warning: control reaches end of non-void function [-Wreturn-type]
   30 | }
      |  ^
Language: C++

#include<iostream>
using namespace std;

int bubbleSort(int A[], int N) {
  int sw = 0;
  int flag = 1;
  while(flag) {
    flag = 0;
    for ( int j = N - 1; 0 < j; j--) {
      if (A[j] < A[j-1]) {
        swap(A[j-1], A[j]);
        sw++; 
        flag = 1;
      }
  }
  return sw;
}

int main() {
  int A[100], N, sw;
  cin >> N;
  for ( int i = 0; i < N; i++ ) {
    if (i) cout << " ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;

  return 0;
}


Compiler output:
a.cc: In function 'int bubbleSort(int*, int)':
a.cc:19:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   19 | int main() {
      |         ^~
a.cc:19:9: note: remove parentheses to default-initialize a variable
   19 | int main() {
      |         ^~
      |         --
a.cc:19:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:19:12: error: a function-definition is not allowed here before '{' token
   19 | int main() {
      |            ^
a.cc:30:2: error: expected '}' at end of input
   30 | }
      |  ^
a.cc:4:32: note: to match this '{'
    4 | int bubbleSort(int A[], int N) {
      |                                ^
a.cc:30:2: warning: control reaches end of non-void function [-Wreturn-type]
   30 | }
      |  ^
Language: C++

#include<iostream>
using namespace std;
int bubbleSort(int A[],int N){
 int sw = o;
 bool flog = 1;
 for(int i = 0; flag; i++){
   flog = 0;
   for(int j = N -1; j >= i + 1; j--){
        if(A[j] < A[j - 1]){
          swap(A[j],A[j - 1]);
          flog = 1;
          sw++;
}
}
}
return sw;
}

int main(){
int A[100], N, sw;
cin >> N;
for(int i = 0; i < N; i++){
   if(i)cout << " ";
   cout << A[i];
   }
     cout <<endi;
     cout << sw << endi;

return 0;
}


Compiler output:
a.cc: In function 'int bubbleSort(int*, int)':
a.cc:4:11: error: 'o' was not declared in this scope
    4 |  int sw = o;
      |           ^
a.cc:6:17: error: 'flag' was not declared in this scope; did you mean 'flog'?
    6 |  for(int i = 0; flag; i++){
      |                 ^~~~
      |                 flog
a.cc: In function 'int main()':
a.cc:26:13: error: 'endi' was not declared in this scope
   26 |      cout <<endi;
      |             ^~~~
Language: C++

#include<iostream>
using namespace std;
int bubbleSort(int A[],int N){
 int sw = o;
 bool flog = 1;
 for(int i = 0; flag; i++){
   flog = 0;
   for(int j = N -1; j >= i + 1; j--){
        if(A[j] < A[j - 1]){
          swap(A[j],A[j - 1]);
          flog = 1;
          sw++;
}
}
}
return sw;
}

int main(){
int A[100], N, sw;
cin >> N;
for(int i = 0; i < N; i++){
   if(i)cout << " ";
   cout << A[i];
   }
     cout <<endl;
     cout << sw << endl;

return 0;
}


Compiler output:
a.cc: In function 'int bubbleSort(int*, int)':
a.cc:4:11: error: 'o' was not declared in this scope
    4 |  int sw = o;
      |           ^
a.cc:6:17: error: 'flag' was not declared in this scope; did you mean 'flog'?
    6 |  for(int i = 0; flag; i++){
      |                 ^~~~
      |                 flog
Language: C++

#include<iostream>
using namespace std;

int bubbleSort(int A[], int N){
 int sw = 0;
 bool flog = 1;
 for(int i = 0; flag; i++){
   flog = 0;
   for(int j = N -1; j >= i + 1; j--){
        if(A[j] < A[j - 1]){
          swap(A[j],A[j - 1]);
          flog = 1;
          sw++;
}
}
}
return sw;
}

int main(){
int A[100], N, sw;
cin >> N;
for(int i = 0; i < N; i++){
   if(i)cout << " ";
   cout << A[i];
   }
     cout <<endi;
     cout << sw << endi;

return 0;
}


Compiler output:
a.cc: In function 'int bubbleSort(int*, int)':
a.cc:7:17: error: 'flag' was not declared in this scope; did you mean 'flog'?
    7 |  for(int i = 0; flag; i++){
      |                 ^~~~
      |                 flog
a.cc: In function 'int main()':
a.cc:27:13: error: 'endi' was not declared in this scope
   27 |      cout <<endi;
      |             ^~~~
Language: C++

#include<iostream>
using namespace std;

int bubbleSort(int A[], int N){
 int sw = 0;
 bool flag = 1;
 for(int i = 0; flag; i++){
   flog = 0;
   for(int j = N -1; j >= i + 1; j--){
        if(A[j] < A[j - 1]){
          swap(A[j],A[j - 1]);
          flog = 1;
          sw++;
}
}
}
return sw;
}

int main(){
int A[100], N, sw;
cin >> N;
for(int i = 0; i < N; i++){
   if(i)cout << " ";
   cout << A[i];
   }
     cout <<endi;
     cout << sw << endi;

return 0;
}


Compiler output:
a.cc: In function 'int bubbleSort(int*, int)':
a.cc:8:4: error: 'flog' was not declared in this scope; did you mean 'flag'?
    8 |    flog = 0;
      |    ^~~~
      |    flag
a.cc: In function 'int main()':
a.cc:27:13: error: 'endi' was not declared in this scope
   27 |      cout <<endi;
      |             ^~~~
Language: C++

#include<iostream>
using namespace std;

int bubbleSort(int A[], int N){
 int sw = 0;
 bool flag = 1;
 for(int i = 0; flag; i++){
   flog = 0;
   for(int j = N -1; j >= i + 1; j--){
        if(A[j] < A[j - 1]){
          swap(A[j],A[j - 1]);
          flog = 1;
          sw++;
}
}
}
return sw;
}

int main(){
int A[100], N, sw;
cin >> N;
for(int i = 0; i < N; i++){
   if(i)cout << " ";
   cout << A[i];
   }
     cout <<endl;
     cout << sw << endl;

return 0;
}


Compiler output:
a.cc: In function 'int bubbleSort(int*, int)':
a.cc:8:4: error: 'flog' was not declared in this scope; did you mean 'flag'?
    8 |    flog = 0;
      |    ^~~~
      |    flag
Language: C++

#include<iostream>
using namespace std;

int bubblesort(int A[], int N){
 int sw=0;
 bool flag=1;
for(int i=0; flag; i++){
 flag = 0;
 for(int j=N-1;i>=i+1;j--){
  if(A[j]<A[j-1]){
    swap(A[j],A[j-1]);
    flag=1;
    sw++;
   }
  }
 } 
return sw;
}
int main(){
 int A[100],N,sw;
 cin>>N;
 for(int i=0;i<n;i++)cin>>A[i];
 
 sw=bubblesort(A,N);

 for(int i=0;i<N;i++){
  if(i) cout<<" ";
  cout<<A[i];
 }
 cout<<endl;
 cout<<sw<<endl;

return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:16: error: 'n' was not declared in this scope
   22 |  for(int i=0;i<n;i++)cin>>A[i];
      |                ^
Language: C++


#include<iostream>

using namespace std;

// bubbleSort:BBS

int BBS(int A[10000],int N){
	int sw=0;//ソートの回数

	bool FLAG=1;

	for(int i=0;flag;i++){

		flag=0;

		for(int j=N-1;j>=i;j--){

			if(A[j]<A[j-1]){

				swap(A[j],A[j-1]);

				flag=1;

			}

			sw++;

		}

	}

	return sw;

}

 

int main{

	int N,sw,A[10000];

	cin >> N;

	for(int i=0;i<N;i++){

		cin >> A[i];

}

	sw = BBS(A,N);

	for(int i=0;i<N;i++){
		if(i)cout << " ";
		cout << A[i];
	}
    cout << endl;
	cout << sw << endl;

	}

}
}


Compiler output:
a.cc: In function 'int BBS(int*, int)':
a.cc:13:21: error: 'flag' was not declared in this scope
   13 |         for(int i=0;flag;i++){
      |                     ^~~~
a.cc: At global scope:
a.cc:39:5: error: cannot declare '::main' to be a global variable
   39 | int main{
      |     ^~~~
a.cc:41:9: error: expected primary-expression before 'int'
   41 |         int N,sw,A[10000];
      |         ^~~
a.cc:41:9: error: expected '}' before 'int'
a.cc:39:9: note: to match this '{'
   39 | int main{
      |         ^
a.cc:43:9: error: 'cin' does not name a type
   43 |         cin >> N;
      |         ^~~
a.cc:45:9: error: expected unqualified-id before 'for'
   45 |         for(int i=0;i<N;i++){
      |         ^~~
a.cc:45:21: error: 'i' does not name a type
   45 |         for(int i=0;i<N;i++){
      |                     ^
a.cc:45:25: error: 'i' does not name a type
   45 |         for(int i=0;i<N;i++){
      |                         ^
a.cc:51:9: error: 'sw' does not name a type
   51 |         sw = BBS(A,N);
      |         ^~
a.cc:53:9: error: expected unqualified-id before 'for'
   53 |         for(int i=0;i<N;i++){
      |         ^~~
a.cc:53:21: error: 'i' does not name a type
   53 |         for(int i=0;i<N;i++){
      |                     ^
a.cc:53:25: error: 'i' does not name a type
   53 |         for(int i=0;i<N;i++){
      |                         ^
a.cc:57:5: error: 'cout' does not name a type
   57 |     cout << endl;
      |     ^~~~
a.cc:58:9: error: 'cout' does not name a type
   58 |         cout << sw << endl;
      |         ^~~~
a.cc:60:9: error: expected declaration before '}' token
   60 |         }
      |         ^
a.cc:62:1: error: expected declaration before '}' token
   62 | }
      | ^
a.cc:63:1: error: expected declaration before '}' token
   63 | }
      | ^
Language: C++

#include<iostream>
using namespace std;
int BBS(int A[10000],int N){
	int sw=0;
	bool flag=1;
	for(int i=0;flag;i++){

		flag=0;

		for(int j=N-1;j>=i;j--){

			if(A[j]<A[j-1]){

				swap(A[j],A[j-1]);

				flag=1;

			}

			sw++;

		}

	}

	return sw;

}

 

int main{

	int N,sw,A[10000];

	cin >> N;

	for(int i=0;i<N;i++){

		cin >> A[i];

}

	sw = BBS(A,N);

	for(int i=0;i<N;i++){
		if(i)cout << " ";
		cout << A[i];
	}
    cout << endl;
	cout << sw << endl;

	}

}
}


Compiler output:
a.cc:32:5: error: cannot declare '::main' to be a global variable
   32 | int main{
      |     ^~~~
a.cc:34:9: error: expected primary-expression before 'int'
   34 |         int N,sw,A[10000];
      |         ^~~
a.cc:34:9: error: expected '}' before 'int'
a.cc:32:9: note: to match this '{'
   32 | int main{
      |         ^
a.cc:36:9: error: 'cin' does not name a type
   36 |         cin >> N;
      |         ^~~
a.cc:38:9: error: expected unqualified-id before 'for'
   38 |         for(int i=0;i<N;i++){
      |         ^~~
a.cc:38:21: error: 'i' does not name a type
   38 |         for(int i=0;i<N;i++){
      |                     ^
a.cc:38:25: error: 'i' does not name a type
   38 |         for(int i=0;i<N;i++){
      |                         ^
a.cc:44:9: error: 'sw' does not name a type
   44 |         sw = BBS(A,N);
      |         ^~
a.cc:46:9: error: expected unqualified-id before 'for'
   46 |         for(int i=0;i<N;i++){
      |         ^~~
a.cc:46:21: error: 'i' does not name a type
   46 |         for(int i=0;i<N;i++){
      |                     ^
a.cc:46:25: error: 'i' does not name a type
   46 |         for(int i=0;i<N;i++){
      |                         ^
a.cc:50:5: error: 'cout' does not name a type
   50 |     cout << endl;
      |     ^~~~
a.cc:51:9: error: 'cout' does not name a type
   51 |         cout << sw << endl;
      |         ^~~~
a.cc:53:9: error: expected declaration before '}' token
   53 |         }
      |         ^
a.cc:55:1: error: expected declaration before '}' token
   55 | }
      | ^
a.cc:56:1: error: expected declaration before '}' token
   56 | }
      | ^
Language: C++

#include<iostream>
#include<vector>
using namespace std;

void trace(const vector<int>& A) {
    for(int i = 0; i < A.size(); i++) {
      if (i > 0) {
        cout << " ";
      }
      cout << A[i];
    }
    cout << endl;
}

int bubbleSort(vector<int>& A) {
  int sw = 0;
  bool flag = 1;

  for (int i = 0; flag; i++) {
    flag = 0;
    for (int j = A.size() - 1; j >= i + 1; j--) {
      if (A[j] < A[j-1]) {
        swap(A[j], A[j-1]);
        flag = 1;
        sw++;
      }
    }
  }
  return sw;
}

int main(){
  vector<int> A;
  A.reserve(100);

  int N, a;
  cin >> N;
  while(N--){
    cin >> a;
    A.push_back(a);
  }

  bubbleSort(A);

  trace(A);
  cout << sw << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:46:11: error: 'sw' was not declared in this scope
   46 |   cout << sw << endl;
      |           ^~
Language: C++

# include <stdio.h>

int bubbleSort(int *A, int N) {
    int flag = 1, count=0;
    while(flag) {
        flag = 0;
        for (int j=N-1; J>0; j--) {
            if (A[j] < A[j-1]) {
                int tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                count++;
            }
            flag = 1;
        }
    }
    return count;
}

void outoutArray(int *A, int N) {
    printf("%d", A[0]);
    for (int i=1; i<N; i++) {
        printf(" %d", A[i]);
    }
    printf("\n");
}

int main() {
    int n;
    scanf("%d", n);
    
    int a[n];
    for (int i=0; i<n; i++) scanf("%d", a[i]);
    
    int count = bubbleSort(a, n);
    outputArray(a, n);
    printf("%d\n", count);
    
    return 0;
}


Compiler output:
a.cc: In function 'int bubbleSort(int*, int)':
a.cc:7:25: error: 'J' was not declared in this scope
    7 |         for (int j=N-1; J>0; j--) {
      |                         ^
a.cc: In function 'int main()':
a.cc:36:5: error: 'outputArray' was not declared in this scope; did you mean 'outoutArray'?
   36 |     outputArray(a, n);
      |     ^~~~~~~~~~~
      |     outoutArray
Language: C++

#include <iostream>
#include "algorithm"
using namespace std;

int main() {
    int n;
    int *a;

    cin >> n;
    a = new int [n];
    for ( int i = 0; i <n ; i++ ) {
        cin >> a[i] ;
    }

    int sw = 0;
    for (int i = 0; i < n; i++) {
        for (int j = n -1; j >= i + 1; j--) {
            if (a[j] < a[j-1]) {
                swap(a[j], a[j-1]);
                sw++;
            }
        }
    }

    for (int i = 0; i < n ; i++) {
        if (i) cout << " "
        cout << a[i] ;
    }
    cout << endl << sw ;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:26:27: error: expected ';' before 'cout'
   26 |         if (i) cout << " "
      |                           ^
      |                           ;
   27 |         cout << a[i] ;
      |         ~~~~
Language: C++

#include <iostream>
#include "algorithm"
using namespace std;

int main() {
    int n;
    int *a;

    cin >> n;
    a = new int [n];
    for ( int i = 0; i <n ; i++ ) {
        cin >> a[i] ;
    }

    int sw = 0;
    for (int i = 0; i < n; i++) {
        for (int j = n -1; j >= i + 1; j--) {
            if (a[j] < a[j-1]) {
                swap(a[j], a[j-1]);
                sw++;
            }
        }
    }

    for (int i = 0; i < n ; i++) {
        if (i) cout << " "
        cout << a[i] ;
    }
    cout << endl << sw << endl;
    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:26:27: error: expected ';' before 'cout'
   26 |         if (i) cout << " "
      |                           ^
      |                           ;
   27 |         cout << a[i] ;
      |         ~~~~
Language: C++

using System;
using System.Collections.Generic;
using System.Linq;

namespace Aizu
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var data = Console.ReadLine().Split(' ').Select(d => int.Parse(d)).ToList<int>();

            int changeCount = 0;
            int num = 1;
            for(int i = data.Count() - 1;  -1 < i; i--)
            {
                for(int j = 0; j < i; j++)
                {
                    if (data[j + 1] < data[j])
                    {
                        var temp = data[j];
                        data[j] = data[j + 1];
                        data[j + 1] = temp;
                        changeCount++;
                    }
                }
                num++;
            }

            Console.WriteLine(string.Join(" ", (string[])data.Select(d => d.ToString())));
            Console.WriteLine(changeCount);
        }
    }

}



Compiler output:
a.cc:1:7: error: expected nested-name-specifier before 'System'
    1 | using System;
      |       ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
    2 | using System.Collections.Generic;
      |       ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
    3 | using System.Linq;
      |       ^~~~~~
a.cc:9:26: error: 'string' has not been declared
    9 |         static void Main(string[] args)
      |                          ^~~~~~
a.cc:9:35: error: expected ',' or '...' before 'args'
    9 |         static void Main(string[] args)
      |                                   ^~~~
a.cc:34:6: error: expected ';' after class definition
   34 |     }
      |      ^
      |      ;
a.cc: In static member function 'static void Aizu::Program::Main(int*)':
a.cc:11:13: error: 'var' was not declared in this scope
   11 |             var n = int.Parse(Console.ReadLine());
      |             ^~~
a.cc:12:17: error: expected ';' before 'data'
   12 |             var data = Console.ReadLine().Split(' ').Select(d => int.Parse(d)).ToList<int>();
      |                 ^~~~
a.cc:16:25: error: 'data' was not declared in this scope
   16 |             for(int i = data.Count() - 1;  -1 < i; i--)
      |                         ^~~~
a.cc:22:29: error: expected ';' before 'temp'
   22 |                         var temp = data[j];
      |                             ^~~~
a.cc:24:39: error: 'temp' was not declared in this scope
   24 |                         data[j + 1] = temp;
      |                                       ^~~~
a.cc:31:13: error: 'Console' was not declared in this scope
   31 |             Console.WriteLine(string.Join(" ", (string[])data.Select(d => d.ToString())));
      |             ^~~~~~~
a.cc:31:31: error: 'string' was not declared in this scope
   31 |             Console.WriteLine(string.Join(" ", (string[])data.Select(d => d.ToString())));
      |                               ^~~~~~
a.cc:31:56: error: expected primary-expression before ']' token
   31 |             Console.WriteLine(string.Join(" ", (string[])data.Select(d => d.ToString())));
      |                                                        ^
Language: C++

#include<stdio.h>

int main(){
  int A[100], n, i, j, t, sw = 0

  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);

  for ( i = 0; i < n; i++ ){
    for ( j = n-1; j >= i+1; j-- ){
      if ( A[j] < A[j-1] ){
	t = A[j]; A[j] = A[j-1]; A[j-1] = t;
	sw++;
      }
    }
  }

  for ( i = 0; i < n; i++ ){
    if (i) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:6:3: error: expected ',' or ';' before 'scanf'
    6 |   scanf("%d", &n);
      |   ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int num;
    cin>>num;
    int a[num];
    int tmp=0;
    for(int i=0;i<num;i++)
        cin>>a[i];
    for(int i=0;i<num;i++)
        {for(int j=num-1;j>i;j--)
         if(a[j]>a[j-1])
          {swap(a[j],a[j-1])
          tmp+=1;}
        }
     for(int i=0;i<num;i++) 
     if(i==num-1)cout<<a[i]<<endl;
     else cout<<a[i]<<" ";
     cout<<tmp<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:29: error: expected ';' before 'tmp'
   14 |           {swap(a[j],a[j-1])
      |                             ^
      |                             ;
   15 |           tmp+=1;}
      |           ~~~
Language: C++

#include<iostream>
using namespace std;

//flag を用いたバブルソート

int bubbleSort(int A[],int N){
  int sw = 0;
  bool flag = 1;
  for (int i = 0; flag; i++){
    flag = 0;
    for( int j = N - 1; j >= i + 1; j--){
      if( A[j] < A[j - 1]){
	//隣接要素を交換する。
	swap(A[j],A[j - 1]);
	flag = 1;
	sw++;
      }
    }
  }
  return sw;
}

int main(){
  int A[100],N,sw;
  cin >> N;
  for(int i =0;i < N; i++)cin >> A[i];

  sw = bubbleSort(A,N);

  for(int i =0; i < N; i++){
    if(i) cout << " ";
    cout << A[i];
  }
  cout << end1;
  cout << sw << end1;

  return 0;

}




Compiler output:
a.cc: In function 'int main()':
a.cc:34:11: error: 'end1' was not declared in this scope
   34 |   cout << end1;
      |           ^~~~
Language: C++

include<iostream>
using namespace std;
int Bsort(int A[],int N){
  int x=0;
  bool flag=1;
  for(int i=0;flag;i++)
    {
      flag=0;
      for(int j=N-1;j>=i+1;j--)
        {
          if(A[j]<A[j-1])
            {
              swap(A[j],A[j-1]);
              flag=1;
              x++;
            }
        }
    }
  return x;
}

int main(){
  int A[100],N,x;
  cin>>N;
  for(int i=0;i<N;i++)cin>>A[i];
  x=Bsort(A,N);
  for(int i=0;i<N;i++)
    {
      if(i)cout<<"";
      cout<<A[i];
    }
  cout<<endl;
  cout<<x<<endl;
  return 0;
}







Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include<iostream>
      | ^~~~~~~
a.cc: In function 'int Bsort(int*, int)':
a.cc:13:15: error: 'swap' was not declared in this scope
   13 |               swap(A[j],A[j-1]);
      |               ^~~~
a.cc: In function 'int main()':
a.cc:24:3: error: 'cin' was not declared in this scope
   24 |   cin>>N;
      |   ^~~
a.cc:29:12: error: 'cout' was not declared in this scope
   29 |       if(i)cout<<"";
      |            ^~~~
a.cc:30:7: error: 'cout' was not declared in this scope
   30 |       cout<<A[i];
      |       ^~~~
a.cc:32:3: error: 'cout' was not declared in this scope
   32 |   cout<<endl;
      |   ^~~~
a.cc:32:9: error: 'endl' was not declared in this scope
   32 |   cout<<endl;
      |         ^~~~
Language: C++

N = int(input())
l = input().split()
l = [int(s) for s in l]
count = 0
for j in range(N):
    for i in range(N-1):
        if( l[i] > l[i+1]):
            l[i], l[i+1] = l[i+1], l[i]
            count += 1
for i in range(0,len(l)-1):
    print(l[i],end=' ')
print(l[N-1])
print(count)



Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
Language: C++

#include<iostream>
using namespace std;

// flagを用いたバブルソート
int bubbleSort(int A[], int N) {
  int sw_cnt = 0;
  bool flag = 1; // 1:未完了 | 0:完了
  // iを増やしながら、flagの値によるwhileをforで再現
  for (int i = 0; flag; i++) {
    // 何もなければ完了とする
    flag = 0;
    //iが下から迫り、jが上から迫るので、徐々に探索範囲は狭まる
    for (int j = N - 1; j >= i + 1; j--) {
      if (A[j] < A[j - 1]) {
        swap(A[j], A[j - 1]);
        // 交換がある限りは未完了にする
        flag = 1;
        sw_cnt++;
      }
    }
  }
  return sw
}

int main() {
  int N, sw_cnt;
  cin >> N;
  int A[N];
  for (int i = 0; i < N; i++) cin >> A[i];

  sw_cnt = bubbleSort(A, N);

  for (int i = 0; i < N; i++) {
    //  最初(i=0)以外は自分の前にスペースを置く
    if (i) cout << " ";
    cout << A[i];
  }

  cout << endl;
  cout << sw_cnt << endl;

  return 0;
}



Compiler output:
a.cc: In function 'int bubbleSort(int*, int)':
a.cc:22:10: error: 'sw' was not declared in this scope
   22 |   return sw
      |          ^~
a.cc:22:12: error: expected ';' before '}' token
   22 |   return sw
      |            ^
      |            ;
   23 | }
      | ~
Language: C++

#include<iostream>
using namespace std;
int bubbleSort(int p[],int n)
{
   // int flag=1;
    int count=0;
    for(int i=0;i<n-1;i++){
      //  if(!flag)break;
      //  flag=0;
        for(int j=n-1;j>i;j--)
           if(p[j]<p[j-1]){
               flag=1;
               int t=p[j];
               p[j]=p[j-1];
               p[j-1]=t;
               count++;
           }
    }
    return count;
}
int main(){
    int n;
    cin>>n;
    int *p=new int[n];
    for(int i=0;i<n;i++) cin>>p[i];
    
    int m=bubbleSort(p,n);
    for(int i=0;i<n-1;i++) 
        cout<<p[i]<<' ';
    cout<<p[n-1]<<endl;
    cout<<m<<endl;
    
    
}


Compiler output:
a.cc: In function 'int bubbleSort(int*, int)':
a.cc:12:16: error: 'flag' was not declared in this scope
   12 |                flag=1;
      |                ^~~~