- #include
- #define week 7
- int main(void) {
- int days;
- while (days > 0)
- {
- }
- return 0;
- }
/* Programming Exercise 5-3 */
#include
int main(void)
{
const int daysperweek = 7;
int days, weeks, day_rem;
printf("Enter the number of days: ");
scanf("%d", &days);
while (days > 0)
{
weeks = days / daysperweek;
day_rem = days ysperweek;
printf("ays are %d weeks and ays.n",
days, weeks, day_rem);
printf("Enter the number of days (0 or less to end): ");
scanf("%d", &days);
}
printf("Done!n");
return 0;
}
위에는 문제보고 제가 푼거고
아래는 답지인데요
사실 저도 맞은 것 같은데 아래는 weeks랑 day_rem 변수를 선언해서 전달인수에 변수를 넣었더라구요
저는 전달인수에 수식을 넣었는데 아래처럼 하는게 더 좋거나 프로그램이 빠르다거나 있나요 ?
댓글 0