怎样用if多分支语句编写
c语言,用if语句编写程序,输入一个星期的某一天,判断这一天是否有c语言课
solution1:
if(xxxx)
{
xxxxx;
}
else if(xxxx)
{
xxxxx;
}
else if(xxxx)
{
xxxxx;
}
...
else
{
xxxxx;
}
solution2:
switch(xxx)
{
case xxx:
break;
case xxx:
break;
....
default:
break;
}
solution3:
change the condition to a int or uint, then use a table to chose it.such as:
/*do some define*/
typedef void (func_t*)(int x)
func_t table[x] = {func1, func2, func3,...}
/*when condition i(the same as if(condition == i) funci)*/
table[i](x)