C语言的几个编程题
1。假设今天是星期日,编写一程序,求12345天后是星期几。2。请编写程序输出1至100以内的能被6整除的整数请详细解释一下。我真不懂这个高级语言-..-...
1。假设今天是星期日,编写一程序,求12345天后是星期几。
2。请编写程序输出1至100以内的 能被6整除的整数
请详细解释一下。我真不懂这个高级语言-..- 展开
2。请编写程序输出1至100以内的 能被6整除的整数
请详细解释一下。我真不懂这个高级语言-..- 展开
1个回答
展开全部
第一题
#include<stdio.h>
#define daysweek 7
#define afterdays 12345
enum
{
Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
};
main()
{
int day = afterdays%daysweek;
switch(day)
{
case Sunday:
printf("after 12345 days is Sunday");
break;
case Monday:
printf("after 12345 days is Monday");
break;
case Tuesday:
printf("after 12345 days is Tuesday");
break;
case Wednesday:
printf("after 12345 days is Wednesday");
break;
case Thursday:
printf("after 12345 days is Thursday");
break;
case Friday:
printf("after 12345 days is Friday");
break;
case Saturday:
printf("after 12345 days is Saturday");
break;
default:
break;
}
}
第二题:
#include<stdio.h>
main()
{
int num;
for(num=1;num<=100;num++)
{
if((num % 6) == 0)
printf("%d\n", num);
}
}
#include<stdio.h>
#define daysweek 7
#define afterdays 12345
enum
{
Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday,
};
main()
{
int day = afterdays%daysweek;
switch(day)
{
case Sunday:
printf("after 12345 days is Sunday");
break;
case Monday:
printf("after 12345 days is Monday");
break;
case Tuesday:
printf("after 12345 days is Tuesday");
break;
case Wednesday:
printf("after 12345 days is Wednesday");
break;
case Thursday:
printf("after 12345 days is Thursday");
break;
case Friday:
printf("after 12345 days is Friday");
break;
case Saturday:
printf("after 12345 days is Saturday");
break;
default:
break;
}
}
第二题:
#include<stdio.h>
main()
{
int num;
for(num=1;num<=100;num++)
{
if((num % 6) == 0)
printf("%d\n", num);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询