#include<stdio.h>#define _CRT_SECURE_NO_WARNINGSvoid sort(int *x, int n){ int i, j,temp; for (i = n-1; i>0; i--) { for (j = 0; j <i; j++) { if (x[j] < x[j + 1]) { temp = x[j]; x[j] = x[j + 1]; x[j + 1] = temp; } } }}void main(){ FILE*fp; int *p, i, a[10]; fp = fopen_s(&fp, "D:\\array.out", "w"); p = a; printf("Input 10 numbers:"); for (i = 0; i<10; i++) scanf("%d", p++); p = a; sort(p, 10); for (; p<a + 10; p++) { printf("%d\n", *p); fprintf(fp, "%d", *p); } fclose(fp);}
添加回答
举报
0/150
提交
取消