Language: C

#include<stdio.h>

void bubblesort(*char,*int,int);
void selectionsort(*char,*int,int);
int isStable(*char,*int,*char,*int,int);

int main(void)
{
int N,i;
scanf("%d\n",&N);
int number[N];
char suit[N];
for(i=0;i<N;i++) scanf("%c%d ",&suit[i],&number[i]);
bubblesort(suit,number,N);
selectionsort(suit,number,N);
return 0;
}

void selectionsort(char *tagin,int *arrayin,int N)
{
int i,mini,j,a,arrayout[N];
char tagout[N],tagA;
memcpy(tagout,tagin,sizeof(tagin));
memcpy(arrayout,arrayin,sizeof(arrayin));
for(i=0;i<N-1;i++)
{
mini=i;
for(j=i+1;j<N;j++)
{
if(arrayout[j]<arrayout[mini]) mini=j;
}
a=arrayout[i],tagA=tagout[i];
arrayout[i]=arrayout[mini],tagout[i]=tagout[mini];
arrayout[mini]=a,tagout[mini]=tagout[i];
}
for(i=0;i<N-1;i++) printf("%c%d ",tagout[i],arrayout[i]);
printf("%c%d\n",tagout[N-1],arrayout[N-1]);
if(isStable(tagin,arrayin,tagout,arrayout,N)) printf("Stable\n");
else printf("not Stable\n");
}

void bubblesort(char *tagin,int *arrayin,int N)
{
int i=0,j,flag=1,a,arrayout[N];
char tagout[N],tagA;
while flag
{
flag=0;
for(j=N-1;j>i;j--)
{
if(arrayout[j]<arrayout[j-1])
{
a=arrayout[j],tagA=tagout[j];
arrayout[j]=arrayout[j-1],tagout[j]=tagout[j-1];
arrayout[j-1]=a,tagout[j-1]=tagA;
flag=1;
}
}
i++;
}
for(i=0;i<N-1;i++) printf("%c%d ",tag[i],array[i]);
printf("%c%d\n",tagout[N-1],arrayout[N-1]);
if(isStable(tagin,arrayin,tagout,arrayout,N)) printf("Stable\n");
else printf("not Stable\n");
}

int isStable(char *tagin,int *numberin,char *tagout,int *numberout,int N)
{
int i,j,a,b;
for(i=0;i<N;i++)
{
for(j=i+1;j<N;j++)
{
for(a=0;a<N;a++)
{
for(b=a+1;b<n;b++)
{
if(numberin[i]=numberin[j] && numberin[i]==numberout[b] && tagin[i]=tagin[b] && numberin[j]==numberout[a] && tagin[j]=tagin[a] return 0;
}
}
}
}
return 1;
}

Compiler output:
main.c:3:17: error: expected declaration specifiers or '...' before '*' token
    3 | void bubblesort(*char,*int,int);
      |                 ^
main.c:3:23: error: expected declaration specifiers or '...' before '*' token
    3 | void bubblesort(*char,*int,int);
      |                       ^
main.c:4:20: error: expected declaration specifiers or '...' before '*' token
    4 | void selectionsort(*char,*int,int);
      |                    ^
main.c:4:26: error: expected declaration specifiers or '...' before '*' token
    4 | void selectionsort(*char,*int,int);
      |                          ^
main.c:5:14: error: expected declaration specifiers or '...' before '*' token
    5 | int isStable(*char,*int,*char,*int,int);
      |              ^
main.c:5:20: error: expected declaration specifiers or '...' before '*' token
    5 | int isStable(*char,*int,*char,*int,int);
      |                    ^
main.c:5:25: error: expected declaration specifiers or '...' before '*' token
    5 | int isStable(*char,*int,*char,*int,int);
      |                         ^
main.c:5:31: error: expected declaration specifiers or '...' before '*' token
    5 | int isStable(*char,*int,*char,*int,int);
      |                               ^
main.c: In function 'main':
main.c:14:1: error: implicit declaration of function 'bubblesort' [-Wimplicit-function-declaration]
   14 | bubblesort(suit,number,N);
      | ^~~~~~~~~~
main.c:15:1: error: implicit declaration of function 'selectionsort' [-Wimplicit-function-declaration]
   15 | selectionsort(suit,number,N);
      | ^~~~~~~~~~~~~
main.c: At top level:
main.c:19:6: warning: conflicting types for 'selectionsort'; have 'void(char *, int *, int)'
   19 | void selectionsort(char *tagin,int *arrayin,int N)
      |      ^~~~~~~~~~~~~
main.c:15:1: note: previous implicit declaration of 'selectionsort' with type 'void(char *, int *, int)'
   15 | selectionsort(suit,number,N);
      | ^~~~~~~~~~~~~
main.c: In function 'selectionsort':
main.c:23:1: error: implicit declaration of function 'memcpy' [-Wimplicit-function-declaration]
   23 | memcpy(tagout,tagin,sizeof(tagin));
      | ^~~~~~
main.c:2:1: note: include '<string.h>' or provide a declaration of 'memcpy'
    1 | #include<stdio.h>
  +++ |+#include <string.h>
    2 | 
main.c:23:1: warning: incompatible implicit declaration of built-in function 'memcpy' [-Wbuiltin-declaration-mismatch]
   23 | memcpy(tagout,tagin,sizeof(tagin));
      | ^~~~~~
main.c:23:1: note: include '<string.h>' or provide a declaration of 'memcpy'
main.c:38:4: error: implicit declaration of function 'isStable' [-Wimplicit-function-declaration]
   38 | if(isStable(tagin,arrayin,tagout,arrayout,N)) printf("Stable\n");
      |    ^~~~~~~~
main.c: At top level:
main.c:42:6: warning: conflicting types for 'bubblesort'; have 'void(char *, int *, int)'
   42 | void bubblesort(char *tagin,int *arrayin,int N)
      |      ^~~~~~~~~~
main.c:14:1: note: previous implicit declaration of 'bubblesort' with type 'void(char *, int *, int)'
   14 | bubblesort(suit,number,N);
      | ^~~~~~~~~~
main.c: In function 'bubblesort':
main.c:46:7: error: expected '(' before 'flag'
   46 | while flag
      |       ^~~~
      |       (
main.c: In function 'isStable':
main.c:76:13: error: 'n' undeclared (first use in this function)
   76 | for(b=a+1;b<n;b++)
      |             ^
main.c:76:13: note: each undeclared identifier is reported only once for each function it appears in
main.c:78:118: error: lvalue required as left operand of assignment
   78 | if(numberin[i]=numberin[j] && numberin[i]==numberout[b] && tagin[i]=tagin[b] && numberin[j]==numberout[a] && tagin[j]=tagin[a] return 0;
      |                                                                                                                      ^
main.c:78:127: error: expected ')' before 'return'
   78 | if(numberin[i]=numberin[j] && numberin[i]==numberout[b] && tagin[i]=tagin[b] && numberin[j]==numberout[a] && tagin[j]=tagin[a] return 0;
      |   ~                                                                                                                           ^~~~~~~
      |                                                                                                                               )
main.c:79:1: error: expected expression before '}' token
   79 | }
      | ^