View Code of Problem 83

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<malloc.h>
#include<string.h>

struct stu {
	int n;
	int s;
}ab[101];

int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	for (int i = 0;i < a + b;i++) {
		scanf("%d%d", &ab[i].n, &ab[i].s);
	}
	for (int i = a + b - 1;i > 0;i--) {
		int flag = 1;
		for (int j = 0;j < i;j++) {
			if (ab[j].n > ab[j+1].n) {
				struct stu t;
				t = ab[j];
				ab[j] = ab[j + 1];
				ab[j + 1] = t;
				flag = 0;
			}
		}
		if (flag)
			break;
	}
	for (int i = 0;i < a + b;i++) {
		printf("%d %d\n", ab[i].n, ab[i].s);
	}

}

Double click to view unformatted code.


Back to problem 83