Current location - Training Enrollment Network - Mathematics courses - C++ program uses English words to simulate mathematical calculation.
C++ program uses English words to simulate mathematical calculation.
Division is not divisible, and the divisor is 0. Modify it yourself. If required.

# include & ltiostream & gt

# include & lt string & gt

Use? Namespace? std

String? Num[]={ "zero", "one", "two", "three", "four", "five", "six", "seven", "eight" and "nine"};

Invalid? Output (int? k)

{

if(k==0)? Return? ;

Output (k/10);

cout & lt& ltnum[k % 10]& lt; & lt"?" ;

}

int? Master ()

{

do

{

int? a[2]= { 0 };

int? k = 0;

int? t;

String? tmp

And (CIN >; & gttmp)

{

if(tmp=="= ")? Break;

if(tmp=="+"? ||? tmp=="-"? ||? tmp=="*"||? tmp=="/")

{

if(tmp=="+")? t = 0;

if(tmp=="-")? t = 1;

if(tmp=="* ")? t = 2;

if(tmp=="/")? t = 3;

k++;

}

other

{

int? Me;

for(I = 0; ; i++)? {? if(num[i]==tmp)? Break; }

a[k]=a[k]* 10+? Me;

}

}

if(a[0]= = 0 & amp; & ampa[ 1]==0)? Break;

if(t==0)? k = a[0]+a[ 1];

if(t== 1)? k = a[0]-a[ 1];

if(t==2)? k = a[0]* a[ 1];

if(t==3)? k = a[0]/a[ 1];

if(k==0)? Cout & lt& lt "zero"<& ltendl

Or what? Output (k);

}while (true);

Return? 0;

}