1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #pragma warning (disable:4996) #include <stdio.h> #include <stdlib.h> int main() { int num; scanf("%d", &num); double* score = (double*)malloc(sizeof(double) * num); double sum = 0.0; double avg = 0.0; for (int i = 0; i < num; i++) { scanf("%lf", &score[i]); printf("%.2f ", score[i]); sum += score[i]; } avg = sum / num; printf("\nhap : %.2f", sum); printf("\navg : %.2f", avg); return 0; } | cs |
프로그래밍 문제/정올