#include<stdio.h>
int main(){
FILE *infp = fopen("input2.txt","wb");
if(infp == NULL){
printf("file open failed");
return 1;
}
int i,n,arr[200];
scanf("%d", &n);
fwrite(&n, sizeof(int), 1, infp);
for (i = 0; i < n; i++) {
scanf("%d", &arr[i]);
fwrite(&arr[i], sizeof(int), 1, infp);
}
rewind(infp);
fclose(infp);
return 0;
}
#include<stdio.h>
void sort(int arr[],int n){
int i,j;
for(i = 1;i < n;i++){
for(j = 0;j < n - i;j++){
if(arr[j] > arr[j + 1]){
int temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
int main(){
FILE *infp = fopen("input2.txt","rb");
FILE *outfp = fopen("output.txt","wb");
if(infp == NULL||outfp == NULL){
printf("file open failed");
return;
}
int i,n,arr[200];
fread(&n,sizeof(int),1,infp);
for (i = 0; i < n; i++) {
fread(&arr[i], sizeof(int), 1, infp);
}
sort(arr,n);
for (i = 0; i < n; i++) {
fwrite(&arr[i], sizeof(int), 1, outfp);
}
fclose(infp);
fclose(outfp);
return 0;
}