#include <stdio.h>#include <malloc.h>#include <stdlib.h>
void swap(int *a, int *b){ int tmp; tmp = *a; *a = *b; *b = tmp;}void sorting(int *p, int *num_a, int *num_b) { int j, i, index; for (j = 0; j < 9; j++) { index = j; for (i = j + 1; i < 10; i++) { if (p[i] < p[index]) { index = i; } } swap(&p[j], &p[index]); }}void concat_sort(int *p, int *num_a, int *num_b){ int i, j, index; for (int i = 0; i<10; i++) { if (i<5) { p[i] = num_a[i]; } else { p[i] = num_b[i - 5]; } }
sorting(p, num_a, num_b);}void concat(char *s, char *str1, char *str2) {
int cnt;
for (int i = 0; i<10; i++) { if (str1[i] == '\0') { cnt = i; break; } s[i] = str1[i]; } for (int i = 0; i<10; i++) { if (str2[i] == '\0') { s[i+cnt] = '\0'; break; } s[i+cnt] = str2[i]; }
printf("%s\n", s);
}
int main(void){ int num_a[5] = { 20,80,90,50,10 }, num_b[5] = { 40,30,60,70,100 }; int *p = (int*)malloc(sizeof(int) * 10);
concat_sort(p, num_a, num_b);
for (int i = 0; i<10; i++) { printf("%d\n", p[i]); }
char str1[10] = "hello", str2[10] = "world"; char *s = (char*)malloc(sizeof(char) * 20);
concat(s, str1, str2);