Language: Java

import java.util.*;

public class Main{
	private static final Scanner scan = new Scanner(System.in);
	int N;

	public static void main(String[] args){

		N = scan.nextInt();
		String[] cards = new String[N];
		String[] copys = new String[N];
		String[] ins = new String[N];
		for(int i = 0; i < N; i++){
			cards[i] = scan.next();
			copys[i] = cards[i];
			ins[i] = cards[i];
		}

		// ??????????????????
		for(int i = 0; i < N; i++){
			for(int j = N-1; j >= i+1; j--){
				String sj = card[j].substring(1);
				String sjj = cards[j-1].substring(1);
				int vj = Interger.parseInt(sj);
				int vjj = Integer.parseInt(sjj);
				if(vj < vjj){
					String work = cards[j];
					cards[j] = cards[j-1];
					card[j-1] = work;
				}
			}
		}

		for(int i = 0; i < N; i++){
			System.out.printf(i != N-1? "%d " : "%d\n", cards[i]);
		}
		System.out.printf("%s\n", isStable(ins, cards)? "Stable" : "Not stable");

		// ???????????????
		for(int i = 0; i < N; i++){
			int minj = i;
			for(int j = i; i < N; j++){
				String sj = copys[j].substring(1);
				String sjj = copys[minj].substring(1);
				int vj = Integer.parseInt(sj);
				int vjj = Integer.parseInt(sjj);
				if(vj < vjj){
					minj = j;
				}
			}
			if(i != minj){
				String work = copys[minj];
				copys[minj] = copys[i];
				copys[i] = work;
			}
		}

		for(int i = 0; i < N; i++){
			System.out.printf(i != N-1? "%d " : "%d\n", copys[i]);
		}
		System.out.printf("%s\n", isStable(ins, copys)? "Stable" : "Not stable");
	}

	public static boolean isStable(String[] in, String[] out){
		for(int i = 0; i < N; i++){
			for(int j = i+1; j < N; j++){
				for(int a = 0; a < N; a++){
					for(int b = a+1; b < N; b++){
						String si = in[i].substring(1);
						String sj = in[j].substring(1);
						int vi = Integer.parseInt(si);
						int vj = Integer.parseInt(sj);
						if(vi == vj && in[i].equals(out[b]) && in[j].equals(out[a])){
							return false;
						}
					}
				}
			}
		}
		return true;
	}
}

Compiler output:
Main.java:9: error: non-static variable N cannot be referenced from a static context
		N = scan.nextInt();
		^
Main.java:10: error: non-static variable N cannot be referenced from a static context
		String[] cards = new String[N];
		                            ^
Main.java:11: error: non-static variable N cannot be referenced from a static context
		String[] copys = new String[N];
		                            ^
Main.java:12: error: non-static variable N cannot be referenced from a static context
		String[] ins = new String[N];
		                          ^
Main.java:13: error: non-static variable N cannot be referenced from a static context
		for(int i = 0; i < N; i++){
		                   ^
Main.java:20: error: non-static variable N cannot be referenced from a static context
		for(int i = 0; i < N; i++){
		                   ^
Main.java:21: error: non-static variable N cannot be referenced from a static context
			for(int j = N-1; j >= i+1; j--){
			            ^
Main.java:22: error: cannot find symbol
				String sj = card[j].substring(1);
				            ^
  symbol:   variable card
  location: class Main
Main.java:24: error: cannot find symbol
				int vj = Interger.parseInt(sj);
				         ^
  symbol:   variable Interger
  location: class Main
Main.java:29: error: cannot find symbol
					card[j-1] = work;
					^
  symbol:   variable card
  location: class Main
Main.java:34: error: non-static variable N cannot be referenced from a static context
		for(int i = 0; i < N; i++){
		                   ^
Main.java:35: error: non-static variable N cannot be referenced from a static context
			System.out.printf(i != N-1? "%d " : "%d\n", cards[i]);
			                       ^
Main.java:40: error: non-static variable N cannot be referenced from a static context
		for(int i = 0; i < N; i++){
		                   ^
Main.java:42: error: non-static variable N cannot be referenced from a static context
			for(int j = i; i < N; j++){
			                   ^
Main.java:58: error: non-static variable N cannot be referenced from a static context
		for(int i = 0; i < N; i++){
		                   ^
Main.java:59: error: non-static variable N cannot be referenced from a static context
			System.out.printf(i != N-1? "%d " : "%d\n", copys[i]);
			                       ^
Main.java:65: error: non-static variable N cannot be referenced from a static context
		for(int i = 0; i < N; i++){
		                   ^
Main.java:66: error: non-static variable N cannot be referenced from a static context
			for(int j = i+1; j < N; j++){
			                     ^
Main.java:67: error: non-static variable N cannot be referenced from a static context
				for(int a = 0; a < N; a++){
				                   ^
Main.java:68: error: non-static variable N cannot be referenced from a static context
					for(int b = a+1; b < N; b++){
					                     ^
20 errors