1.
#include "stdio.h"
double getAve(int *a,int n)
{
int *p;
int sum=0;
第一个问题:
#include
double aver( double a[], int size )
{
int i;
double sum = 0.0;
for ( i = 0; i < size; i++ )
sum += a[i];
return sum / size;
}
int main()
{
double num[10];
int i;
for ( i = 0; i < 10; i++ )
scanf("%lf", &a[i]);
printf("%lf\n", aver( num, 10 ));
return 0;
}
第二个问题:
#include
void delete( char ch, char a[], int size )
{
int i, j;
for ( i = 0; i < size; i++ )
if ( a[i] == ch )
{
for ( j = i; j < size - 1; j++ )
a[j] = a[j+1];
a[j] = '\0';
i--;
}
}
int main()
{
char a[] = "abcabcaaabc";
char *ptr;
ptr = a;
delete( 'a', a, 11 );
// delete( 'a', ptr, 11 );
printf("%s\n", a);
return 0;
}