Home > Back-end >  Bosses genuflect is begged
Bosses genuflect is begged

Time:06-05

Topics are as follows:
Read the two positive integers A and B is less than 100, calculate A + B, it is important to note: each of A and B A number given by the corresponding English words,
Test the input contains several test cases, each test case A line, the format for "A + B=", adjacent two string has A space interval, when A and B 0 means that the end of the input at the same time, the corresponding results don't output,




#include
#include
Int main ()
{
Char a [10] [10]={" zero ", "one", "two", "three", "four", "five", "six", "seven", "eight" and "nine"};
Char STR [100].
Int j, y=0, z=0, sum=0, b=0, d=0, e=0;
While (b==0)
{
The scanf (" % s ", STR);
for(j=0; j<10; J++)
{
If (STRCMP (STR, a [j])==0)
D=j;
If (STRCMP (STR, "+")==0)
{
b++;
break;
}
Y=y * 10 + d;
}
}
While (b==1)
{
The scanf (" % s ", STR);
for(j=0; j<10; J++)
{
If (STRCMP (STR, a [j])==0)
E=j;
If (STRCMP (STR, "=")==0)
break;
Z=z * 10 + e;
}
}

If (y==0 & amp; & Z==0)
return 0;
Sum=y + z;
Printf (" % d \ n ", sum);
return 0;
}

CodePudding user response:

There is no buckle the question

CodePudding user response:

After modification, the code is as follows:
#include
#include
Int main ()
{
Char a [10] [10]={" zero ", "one", "two", "three", "four", "five", "six", "seven", "eight" and "nine"};
Char STR [100].
Int j, y=0, z=0, sum=0, b=0, d=0, e=0;
While (1)
{
y=0; Z=0; sum=0; b=0; D=0; E=0;
While (b==0)
{
The scanf (" % s ", STR);
for(j=0; j<10; J++)
{
If (STRCMP (STR, a [j])==0)
{
D=j;
Y=y * 10 + d;
}
If (STRCMP (STR, "+")==0)
{
b++;
break;
}

}
}
While (b==1)
{
The scanf (" % s ", STR);
for(j=0; j<10; J++)
{
If (STRCMP (STR, a [j])==0)
{
E=j;
Z=z * 10 + e;
}
If (STRCMP (STR, "=")==0)
break;
}
If (STRCMP (STR, "=")==0)
break;
}

If (y==0 & amp; & Z==0)
return 0;
Sum=y + z;
Printf (" % d \ n ", sum);
}
return 0;
}

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
Prev:c
  • Related