那些bug,大神帮帮窝
#include<iostream>using namespace std ;
int main()
{
int first_num;
int second_num;
int sign;
cout<<"enter the first_number:"<<'\n';
cin>> first_num;
cout<<"enter the second_number:"<<'\n';
cin>>second_num;
cout<<"enter the arithmetic sign :"<<'\n';
cin>>sign;
if ( sign== + )
{
cout<<first_num<<"+"<<second_num<<"="<<first_num + second_num<<endl;
}
else if(sign==-)
{
cout<<first_num<<"-"<<second_num<<"="<<first_num - second_num<<endl;
}
else if(sign==*)
{
cout<<first_num<<"*"<<second_num<<"="<<first_num * second_num<<endl;
}
else(sign==/);
{
cout<<first_num<<"/"<<second_num<<"="<<first_num / second_num<<endl;
return 0;
}
}
报错是:
||=== Build: Debug in 入门练习 (compiler: GNU GCC Compiler) ===|
D:\软件\C++\C++文件\入门练习\main.cpp||In function 'int main()':|
D:\软件\C++\C++文件\入门练习\main.cpp|14|error: expected primary-expression before ')' token|
D:\软件\C++\C++文件\入门练习\main.cpp|18|error: expected primary-expression before ')' token|
D:\软件\C++\C++文件\入门练习\main.cpp|22|error: expected primary-expression before ')' token|
D:\软件\C++\C++文件\入门练习\main.cpp|26|error: expected primary-expression before '/' token|
D:\软件\C++\C++文件\入门练习\main.cpp|26|error: expected primary-expression before ')' token|
||=== Build failed: 5 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
没有弄明白为什么那个地方有错*_*
还有有时候莫名其妙的会报错else if前面应该先用if,可是我用过if了呀。。。网上有人说可能是没有大括号,我加了还是不行T_T
就是有时候好好的有时候会报错,但找不到错跟没错有什么不一样的地方