Language: C++

#include <iostream>





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 bubbleSort(int*, int)':
a.cc:14:18: error: 'swap' was not declared in this scope
   14 |                  swap(A[j], A[j - 1]);
      |                  ^~~~
a.cc:14:18: 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)
      |     ^~~~
a.cc: In function 'int main()':
a.cc:30:1: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   30 | cin >> N;
      | ^~~
      | std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:36:12: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   36 |      if(i) cout << " ";
      |            ^~~~
      |            std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:37:6: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   37 |      cout << A[i];
      |      ^~~~
      |      std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:39:1: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   39 | cout << end1;
      | ^~~~
      | std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:39:9: error: 'end1' was not declared in this scope
   39 | cout << end1;
      |         ^~~~