[정올] Language Coder_반복제어문2_형성평가6_code135 (C)

두비니

·

2020. 3. 27. 05:15

 

 

#include <stdio.h>

int main() {

	int a, b, sum=0, n=0;

	scanf("%d %d", &a, &b);

	if (a > b) {
		int tmp = b;
		b = a;
		a = tmp;
	}

	for (int i = a; i <= b; i++) {
		if (i % 3 == 0 || i % 5 == 0) {
			sum += i;
			n++;
		}
	}

	printf("sum : %d\n", sum);
	printf("avg : %.1f", (double)sum / n);

	return 0;
}