#include <stdio.h> #include <stdlib.h> int main() { int n, i, sum = 0; scanf("%d", &n); int *p = malloc(n * sizeof(int)); if(p != NULL) { for(i = 0; i < n; i++) { scanf("%d", &p[i]); sum += p[i]; } printf("avg is %d\n", sum / n); free(p); } }
2023-12-03 16:00:04
#include <stdio.h> #include <stdlib.h> int main() { int n, i, sum = 0; scanf("%d", &n); int *p = malloc(n * sizeof(int)); if(p != NULL) { for(i = 0; i < n; i++) { scanf("%d", &p[i]); sum += p[i]; } printf("avg is %d\n", sum / n); free(p); } }