小编Dev*_*ere的帖子

错误在我的 C++ 程序中重复大小写值。虽然我什么都改变不了

我试图编写一个程序来帮助我找到给定角度的三角函数值。下面是程序,

    #include<iostream>
#include<cmath>
using namespace std;

void convert(char type);

int main()
{
    char ch;


    cout<<"Enter what angle value u want to calculate: 'c' for cos, 's' for sine and 't' for tan: ",cin>>ch;

    convert(ch);

    return 0;
}

void convert(char type)
{
    float angle;
    double num;
    switch (type)
    {
        case 'C' || 'c':
            cout<<"Enter angle value to calculate cos equivalent: ",cin>>angle;
            num = cos(angle);
            break;
        case 's' || 'S':
            cout<<"Enter angle value to calculate sin equivalent: ",cin>>angle;
            num = sin(angle);
            break; …
Run Code Online (Sandbox Code Playgroud)

c++ case duplicates switch-statement

-2
推荐指数
1
解决办法
1837
查看次数

标签 统计

c++ ×1

case ×1

duplicates ×1

switch-statement ×1