Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
804 B
3
Indexable
Never
#include <stdio.h>
#include <math.h>
void enter(int a[], int *n){
	printf("enter space: ");
 	  scanf("%d", n);
for(int i = 0; i < *n; i++){
	printf("enter a[%d]: ", i+1);
	scanf("%d", &a[i]);
	if(a[i] ==0)
	break;
}
  }
void hien(int a[], int n){
	for(int i = 0; i < n; i++){
		printf("%d ", a[i]);
	}
}
int tongnam(int a[], int n) {
	int sum = 0, den = 0;
	for(int i = 0; i < n; i++){
		abs(a[i]);
		if(a[i] % 5 == 0){
			den++;
		sum += a[i];
		}
	}
	return sum / den;
}
int soamchan(int a[], int n){
	int dem = 0;
	for(int i = 0;i < n; i++){
		if(a[i] < 0 && a[i] % 2 ==0 )
		dem++;
	}
	return dem;
}
int main() {
int a[100], n;
enter(a, &n);
hien(a, n);
printf("\nave number = %d",tongnam(a ,n));
printf("\nco %d so am chan", soamchan(a, n));

return 0;
}