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: In function 'main':
main.c:14:12: error: passing argument 1 of 'bubblesort' makes integer from pointer without a cast [-Wint-conversion]
   14 | bubblesort(suit,number,N);
      |            ^~~~
      |            |
      |            char *
main.c:3:17: note: expected 'char' but argument is of type 'char *'
    3 | void bubblesort(char,int,int);
      |                 ^~~~
main.c:14:17: error: passing argument 2 of 'bubblesort' makes integer from pointer without a cast [-Wint-conversion]
   14 | bubblesort(suit,number,N);
      |                 ^~~~~~
      |                 |
      |                 int *
main.c:3:22: note: expected 'int' but argument is of type 'int *'
    3 | void bubblesort(char,int,int);
      |                      ^~~
main.c:15:15: error: passing argument 1 of 'selectionsort' makes integer from pointer without a cast [-Wint-conversion]
   15 | selectionsort(suit,number,N);
      |               ^~~~
      |               |
      |               char *
main.c:4:20: note: expected 'char' but argument is of type 'char *'
    4 | void selectionsort(char,int,int);
      |                    ^~~~
main.c:15:20: error: passing argument 2 of 'selectionsort' makes integer from pointer without a cast [-Wint-conversion]
   15 | selectionsort(suit,number,N);
      |                    ^~~~~~
      |                    |
      |                    int *
main.c:4:25: note: expected 'int' but argument is of type 'int *'
    4 | void selectionsort(char,int,int);
      |                         ^~~
main.c: At top level:
main.c:19:6: error: conflicting types for 'selectionsort'; have 'void(char *, int *, int)'
   19 | void selectionsort(char *tagin,int *arrayin,int N)
      |      ^~~~~~~~~~~~~
main.c:4:6: note: previous declaration of 'selectionsort' with type 'void(char,  int,  int)'
    4 | void selectionsort(char,int,int);
      |      ^~~~~~~~~~~~~
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:13: error: passing argument 1 of 'isStable' makes integer from pointer without a cast [-Wint-conversion]
   38 | if(isStable(tagin,arrayin,tagout,arrayout,N)) printf("Stable\n");
      |             ^~~~~
      |             |
      |             char *
main.c:5:14: note: expected 'char' but argument is of type 'char *'
    5 | int isStable(char,int,char,int,int);
      |              ^~~~
main.c:38:19: error: passing argument 2 of 'isStable' makes integer from pointer without a cast [-Wint-conversion]
   38 | if(isStable(tagin,arrayin,tagout,arrayout,N)) printf("Stable\n");
      |                   ^~~~~~~
      |                   |
      |                   int *
main.c:5:19: note: expected 'int' but argument is of type 'int *'
    5 | int isStable(char,int,char,int,int);
      |                   ^~~
main.c:38:27: error: passing argument 3 of 'isStable' makes integer from pointer without a cast [-Wint-conversion]
   38 | if(isStable(tagin,arrayin,tagout,arrayout,N)) printf("Stable\n");
      |                           ^~~~~~
      |                           |
      |                           char *
main.c:5:23: note: expected 'char' but argument is of type 'char *'
    5 | int isStable(char,int,char,int,int);
      |                       ^~~~
main.c:38:34: error: passing argument 4 of 'isStable' makes integer from pointer without a cast [-Wint-conversion]
   38 | if(isStable(tagin,arrayin,tagout,arrayout,N)) printf("Stable\n");
      |                                  ^~~~~~~~
      |                                  |
      |                                  int *
main.c:5:28: note: expected 'int' but argument is of type 'int *'
    5 | int isStable(char,int,char,int,int);
      |                            ^~~
main.c: At top level:
main.c:42:6: error: conflicting types for 'bubblesort'; have 'void(char *, int *, int)'
   42 | void bubblesort(char *tagin,int *arrayin,int N)
      |      ^~~~~~~~~~
main.c:3:6: note: previous declaration of 'bubblesort' with type 'void(char,  int,  int)'
    3 | void bubblesort(char,int,int);
      |      ^~~~~~~~~~
main.c: In function 'bubblesort':
main.c:46:7: error: expected '(' before 'flag'
   46 | while flag
      |       ^~~~
      |       (
main.c:63:13: error: passing argument 1 of 'isStable' makes integer from pointer without a cast [-Wint-conversion]
   63 | if(isStable(tagin,arrayin,tagout,arrayout,N)) printf("Stable\n");
      |             ^~~~~
      |             |
      |             char *
main.c:5:14: note: expected 'char' but argument is of type 'char *'
    5 | int isStable(char,int,char,int,int);
      |              ^~~~
main.c:63:19: error: passing argument 2 of 'isStable' makes integer from pointer without a cast [-Wint-conversion]
   63 | if(isStable(tagin,arrayin,tagout,arrayout,N)) printf("Stable\n");
      |                   ^~~~~~~
      |                   |
      |                   int *
main.c:5:19: note: expected 'int' but argument is of type 'int *'
    5 | int isStable(char,int,char,int,int);
      |                   ^~~
main.c:63:27: error: passing argument 3 of 'isStable' makes integer from pointer without a cast [-Wint-conversion]
   63 | if(isStable(tagin,arrayin,tagout,arrayout,N)) printf("Stable\n");
      |                           ^~~~~~
      |                           |
      |                           char *
main.c:5:23: note: expected 'char' but argument is of type 'char *'
    5 | int isStable(char,int,char,int,int);
      |                       ^~~~
main.c:63:34: error: passing argument 4 of 'isStable' makes integer from pointer without a cast [-Wint-conversion]
   63 | if(isStable(tagin,arrayin,tagout,arrayout,N)) printf("Stable\n");
      |                                  ^~~~~~~~
      |                                  |
      |                                  int *
main.c:5:28: note: expected 'int' but argument is of type 'int *'
    5 | int isStable(char,int,char,int,int);
      |                            ^~~
main.c: At top level:
main.c:67:5: error: conflicting types for 'isStable'; have 'int(char *, int *, char *, int *, int)'
   67 | int isStable(char *tagin,int *numberin,char *tagout,int *numberout,int N)
      |     ^~~~~~~~
main.c:5:5: note: previous declaration of 'isStable' with type 'int(char,  int,  char,  int,  int)'
    5 | int isStable(char,int,char,int,int);
      |     ^~~~~~~~
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 | }
      | ^