帮我看看这个c++小程序

来源:百度知道 编辑:UC知道 时间:2024/07/02 19:46:35
这是个计算器程序,请帮我挑挑错好吗?
#include<iostream.h>
#include <stdlib.h>
using namespace std;
int plus(int a,int b)
{return a+b;}
int subtract(int a,int b)
{return a-b;}
int ride(int a,int b)
{return a*b;}
int divide(int a,int b)
{return a/b;}
void main(){
char q,m,n;
q=new char;m=new char;q=new char;
do{
cout<<"enter e to exit!"
cout<<"please enter a number!"
try{
cin>>m;
if(m==e)exit;
elas{
cout<<"please enter a Data types!"
cin>>q;
cout<<"please enter a number!"
cin>>n;
m=atoi(m);
n=atoi(n);
if(q==(+))cout<<plus(m,n);
elas if(q==(-))cout<<subtract(m,n);
elas if(q==(*))cout<<ride(m,n);
elas if(q==(/))cout<<divide(m,n);}
if((m=0||n=0)||(((q!=)+)&&((q!=)-)&&((q!=)/)&&((q!=)*)))
throw "wrong!";}
catch{ex

用#include<iostream.h>就不用加using namespace std; 了。
char 型不需要new
m=atoi(m); n=atoi(n);m,n是char型,atoi()返回值是int型的怎么行?
if((m=0||n=0)||(((q!=)+)&&((q!=)-)&&((q!=)/)&&((q!=)*))) 里的m=0和n=0应改为m==0,n==0 (((q!=)+)这是什么?
.....

你没定屏吧?前面加个#include"conio.h"后面加个getch();试试…再运行生成的可执行文件(.exe)还有,有个else写错了…其他的看编译错误提示…