题目1010:A + B(字符串转数字)

题目链接:http://ac.jobdu.com/problem.php?pid=1010

详解链接:https://github.com/zpfbuaa/JobduInCPlusPlus

参考代码:

//
// 1010 A + B.cpp
// Jobdu
//
// Created by PengFei_Zheng on 28/04/2017.
// Copyright © 2017 PengFei_Zheng. All rights reserved.
// #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <cmath>
#include <vector> using namespace std; #include <stdio.h>
#include <string.h>
char arr[][] = { "zero","one","two","three","four","five","six","seven","eight","nine"};
int find(char* str) {
int i;
for (i = ; i < ; i++) {
if (strcmp(arr[i], str) == )
return i;
}
return ;
}
int main() {
char temp[];
while (scanf("%s", temp) != EOF) {
int a = find(temp);
scanf("%s", temp);
if (temp[] != '+') {
a = a * + find(temp);
scanf("%s", temp);
}
scanf("%s", temp);
int b = find(temp);
scanf("%s", temp);
if (temp[] != '=') {
b = b * + find(temp);
scanf("%s", temp);
}
if(a== && b==)
break;
printf("%d\n", a + b);
}
return ;
}
/**************************************************************
Problem: 1010
User: zpfbuaa
Language: C++
Result: Accepted
Time:0 ms
Memory:1520 kb
****************************************************************/
上一篇:c#RSA的SHA1加密与AES加密、解密


下一篇:14.1.3 检查InnoDB 可用性: