小编TIM*_*THY的帖子

我可以使用开关来保持功能吗?

我有一个3文件程序,基本上自学c ++.我有一个问题.我做了一个开关来使用数学函数.我需要把它放在一个变量中,但由于某种原因我得到一个零.

还有一个问题,当我选择4(除)时它会崩溃......有原因吗?

主文件:

#include <iostream>
#include "math.h"
#include <string>

using namespace std;

int opersel;
int c;
int a;
int b;
string test;

int main(){

cout << "Welcome to Math-matrix v.34"<< endl;
cout << "Shall we begin?" <<endl;

//ASK USER IF THEY ARE READY TO BEGIN 

string answer;
cin >> answer;

if(answer == "yes" || answer == "YES" || answer == "Yes")
{

           cout << "excellent lets begin..." << endl;

           cout << "please select a operator..." << endl  << endl; …
Run Code Online (Sandbox Code Playgroud)

c++ math switch-statement

0
推荐指数
1
解决办法
612
查看次数

标签 统计

c++ ×1

math ×1

switch-statement ×1