int main( )
{
int a[ ] = { 1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 } ;
int sz = 9 ;
int cnt = 0 ;
for ( int i = 1 ; i < sz; ++ i)
{
for ( int j = i; j > 0 ; -- j)
{
cnt+ = 1 ;
if ( a[ j] < a[ j - i] )
swap( a[ j] , a[ j - 1 ] ) ;
}
}
printf ( "%d" , cnt) ;
return 0 ;
}
aW50IG1haW4oKQp7CiAgICBpbnQgYVtdID0gezEsMiwzLDQsNSw2LDcsOCw5fTsKICAgIGludCBzeiA9IDk7CiAgICBpbnQgY250ID0gMDsKICAgIGZvcihpbnQgaSA9IDE7IGkgPCBzejsgKytpKQogICAgewogICAgICAgIGZvcihpbnQgaiA9IGk7IGogPiAwOyAtLWopCiAgICAgICAgewogICAgICAgIAljbnQrPTE7CiAgICAgICAgICAgIGlmIChhW2pdIDwgYVtqIC0gaV0pCiAgICAgICAgICAgICAgICBzd2FwKGFbal0sIGFbaiAtIDFdKTsKICAgICAgICB9CiAgICB9CiAgICBwcmludGYoIiVkIiwgY250KTsKICAgIHJldHVybiAwOwp9
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:12:36: error: ‘swap’ was not declared in this scope
swap(a[j], a[j - 1]);
^
prog.cpp:15:21: error: ‘printf’ was not declared in this scope
printf("%d", cnt);
^
stdout