A + B 9-degree OJ

Source: Internet
Author: User
Preface I haven't written 9-degree ACM for a long time. I wrote a Samsung A + B question this evening. The difficulty is to know how to control the input after the input format, provide a way of thinking. After all, C does not have as many system functions as PHP can call. Write down the question requirements and directly go to the AC Code Now
Description:
Read two integers A and B smaller than 100 and calculate a + B.
Note that each digit of A and B is given by the corresponding English word.
Input:
The test input contains several test cases. Each test case occupies one line in the format of "A + B =". There is a space interval between two adjacent strings. when both A and B are 0, the input ends. Do not output the corresponding results.
Output:
Output one line for each test case, that is, the value of A + B.
Sample input:
One + two = three four + Five Six = zero seven + eight nine = zero + zero =
Sample output:
 
39096

AC code
 # include 
    
      # include 
     
       # include 
      
        int strtoint (char *); int main () {char STR [6]; int A, B, C; while (scanf ("% s", STR )) {A = strtoint (STR); While (scanf ("% s", STR) {If (STR [0]! = '+' & STR [0]! = ') {B = strtoint (STR); A = A * 10 + B;} else if (STR [0] =' + ') {c =; a = 0;} else if (STR [0] = ') {break;} If (! A &&! C) {break;} else {printf ("% d \ n", A + C) ;}} return 0 ;}int strtoint (char * Str) {int num; if (strcmp (STR, "zero") = 0) {num = 0;} else if (strcmp (STR, "one") = 0) {num = 1;} else if (strcmp (STR, "two") = 0) {num = 2;} else if (strcmp (STR, "three ") = 0) {num = 3;} else if (strcmp (STR, "four") = 0) {num = 4;} else if (strcmp (STR, "five") = 0) {num = 5;} else if (strcmp (STR, "Six") = 0) {num = 6 ;} else if (strcmp (STR, "Seven") = 0) {num = 7;} else if (strcmp (STR, "eight") = 0) {num = 8;} else if (strcmp (STR, "Nine") = 0) {num = 9 ;}return num ;}
      
     
    

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.