哪位能帮我写2个小程序哈

来源:百度知道 编辑:UC知道 时间:2024/05/19 13:03:52
编写一个程序.要求用户输入今天是星期几.根据用户的输入判定是工作日还是周末,并显示合适的问候语.
1.如果输入的数字不在1~7之间,则显示"请输入位于1~7之间的数".
2.如果用户输入的数字为6或7,则显示"周末愉快!"
3.对于1~5之间的数字,则显示"工作日愉快!"

接受一个字符.例如用"+"表示加法.用"-"表示减法.接受num1和num2两个数.如果输入的字符为"+",则将这两个数相加并显示相应的结果.如果输入的字符为"-",则将这两个数相减并显示相应的结果.

这两个.谁能帮我写下哈..最好明早10点前能搞定啊..30分送上.
忘了说了,用C语言编写~
第二题啊第二题...

第一个问题
#include <stdio.h>

/* define const varible of day */
const int MON = 1;
const int TUE = 2;
const int WED = 3;
const int THU = 4;
const int FRI = 5;
const int SAT = 6;
const int SUN = 7;

void main()
{
int day;
/* get input */
while (1)
{
printf("请输入今天星期几\n");
fflush(stdin);
day = getchar();
day = day - 0x30;
/* verify if the format is right */
if (day >=MON && day <= SUN)
{
break ; /* right format of day */
}
else
{
/* input again */
printf("请输入1-7之间的整数\n");
}
}
/* weekend */
if (SUN == day || SAT == day)
{
printf("周末愉快\n");
}
/* working days */
else
{
printf("工作日愉快\n");
}

}
第二个问题:
#include <stdio.h>

void main()