#ifdef ex_h
#define ex_h
#include
#include
#include
extern const int SIZE;
double *
#ifdef ex_h
#define ex_h
#include
#include
#include
extern const int SIZE;
double *init(int);
void reading(double *);
void product(double *);
void sort(double *,double a[],SIZE);
#endif
#define NULL 0
#define SIZE 10
void main()
{int i;
double *in_1,*in_2;
double a[SIZE];
*in_1=init(SIZE);
if(in_1==NULL)
{printf("Press any key to exit...");
getch();
exit(0);}
reading(in_1,SIZE);
product(in_1,SIZE);
sort(in_1,a,SIZE);
for(i=0;i
*in_2++=a[i]*10;
printf("\nThe numbers you've entered are:\n");
for(i=0;i
{printf("%15f",*in_1++);
if((i+1)%5==0)printf("\n");}
printf("\nThe sort of the %d numbers is:\n",SIZE);
for(i=0;i
{printf("%15f",a[i]);
if((i+1)%5==0) printf("\n");}
printf("\n10 times and opposite order is:\n");
for(i=0;i
{printf("%15f",*--in_2);
if((i+1)%5==0)printf("\n");}
printf("\nThe end!\nThank you for your use.\nPress any key to exit...");
getch();
}
#define NULL 0
double *init(int SIZE)
{double *in=(double *)calloc(SIZE,sizeof(double));
if(in!=NULL) return in;
else {printf("Failed to apply memory addresses.");
return NULL;}
}
void reading(double *in,int SIZE)
{int i;
printf("Please enter %d numbers:\n",SIZE);
for(i=0;i
{printf("the %dth number:",i+1);
scanf("%lf",in++);}
}
void product(double *in,int SIZE)
{int i;
double temp=1;
in+=SIZE-1;
for(i=0;i
temp=(*in--)*temp;
printf("The product of the %d numbers you've entered is:%f\n",SIZE,temp);
printf("Please press any key to continue...\n");
getch();
}
void sort(double *in,double a[],int SIZE)
{int i,j,k;
double temp;
for(i=0;i
a[i]=*in++;
for(i=0;i
{k=i;
for(j=i+1;j
if(a[k]>a[j]) k=j;
if(k!=i)
{temp=a[k];a[k]=a[i];a[i]=temp;}
}
}
展开
全部