下面是一份示例代码:
#include <stdio.h>
int main() {
int num, sum = 0, count = 0;
float avg;
printf("请输入正整数:\n");
while (1) {
scanf("%d", &num);
if (num <= 0) {
break;
}
sum += num;
count++;
}
avg = (float) sum / count;
pr