大师傅

Nicole  •  11天前


 #include <stdio.h>

int main() {
int money, total_count = 0, total_type = 0;
int count_20 = 0, count_10 = 0, count_5 = 0, count_1 = 0;

scanf("%d", &money);

count_20 = money / 20;
money = money % 20;
total_count = total_count + count_20;
if (count_20 > 0) {
	total_type += 1;
}

count_10 = money / 10;
money = money % 10;
total_count = total_count + count_10;
if (count_10 > 0) {
	total_type += 1;
}
count_5 = money / 5;
money = money % 5;
total_count = total_count + count_5;
if (count_5 > 0 ) {
	total_type += 1;
}
count_1 = money / 1;
total_count = total_count + count_1;
if (count_1 > 0 ) {
	total_type += 1;
}

printf("%d %d", total_count, total_type);
return 0;
}

评论:

请先登录,才能进行评论