【发布时间】:2019-10-05 19:32:16
【问题描述】:
int op_type(const char *input, int op_pos)
{
int category;
if (input[op_pos] == '+')
category = 1;
if (input[op_pos] == '*')
category = 2;
if (input[op_pos] == '/')
category = 3;
if (input[op_pos] == '^')
category = 4;
return category;
}
这个函数将用于做基本的数学运算。
【问题讨论】:
-
... 并保留在四个选项中的 none 匹配的事件中返回的不确定值
category的损坏逻辑? -
欢迎来到 Stack Overflow。请阅读the help pages,取the SO tour,阅读有关how to ask good questions,以及this question checklist。
-
您研究过
switch语句并了解其用途吗? -
不清楚
switch的用法和语法你不清楚。请展示您研究过的任何教程中的代码,并解释什么是您的障碍。将显示的代码转换为使用 switch 可能正是 5 个基本 C 教程中有 4 个使用的示例。因此,请理解很难理解您需要解释的内容。仅文档(例如 en.cppreference.com/w/c/language/switch )就已经提供了大量示例。
标签: c computer-science