题目1010:A + B
来源:互联网 发布:完美红颜进阶数据 编辑:程序博客网 时间:2024/06/05 01:03
#include <stdio.h>#include <string.h> char number[10][6] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; void getNum(char str[],int *a,int *b){ int i,j,pos,d,k; char strA[6],strB[6]; int bufA[5],bufB[5]; i = 0; while(str[i] != '\0'){ if(str[i] == '+'){ pos = i; break; } i++; } i = 0; k = 0; while(i < pos){ j = 0; while(str[i] != ' '){ strA[j++] = str[i++]; } i++; strA[j] = '\0'; for(j=0;j<10;j++){ if(strcmp(strA,number[j]) == 0){ bufA[k++] = j; break; } } } d = 1; for(i=k-1;i>=0;i--){ *a += bufA[i]*d; d *= 10; } i = pos+2; k = 0; while(str[i] != '='){ j = 0; while(str[i] != ' '){ strB[j++] = str[i++]; } i++; strB[j] = '\0'; for(j=0;j<10;j++){ if(strcmp(strB,number[j]) == 0){ bufB[k++] = j; break; } } } d = 1; for(i=k-1;i>=0;i--){ *b += bufB[i]*d; d *= 10; }} int main(){ int a,b; char str[50]; while(gets(str) != NULL){ a = b = 0; getNum(str,&a,&b); if(a==0 && b==0){ break; }else{ printf("%d\n",a+b); } } return 0;}/************************************************************** Problem: 1010 User: cust123 Language: C++ Result: Accepted Time:0 ms Memory:1020 kb****************************************************************/
0 0
- 题目1010:A + B
- 题目1010:A + B
- 题目1010:A + B
- 题目1010:A + B
- 题目1010:A + B
- 题目1010:A + B
- 题目1010:A + B
- 题目1010:A + B
- 题目1010:A + B
- 题目1010:A + B
- 题目1010:A + B
- 题目1010:A + B
- 题目1010:A + B
- 九度OJ 题目1010:A + B
- 九度OJ-题目1010:A + B
- 九度 题目1010:A + B
- 九度OJ 题目1010:A + B
- 九度OJ-题目1010:A+B
- 携程2018届实习生招聘在线笔试编程题解 (Java语言)
- cfsetospeed和cfsetispeed函数
- DUBBO的com.alibaba.dubbo.rpc.RpcException远程调用异常解决方法
- Android获取设备唯一ID的几种方式
- smarty的使用和修改包标签方法
- 题目1010:A + B
- Idea license server
- MySQL 数据库
- Ubuntu14 系统下安装Opencv3.0攻略
- C/C++多文件共享全局变量时,使用extern的规范
- vim、gvim在windows下中文乱码的终极解决方案
- BZOJ2258 文本校对 (Splay Hash 二分答案)
- Service的onStartCommand中报空指针问题
- NOI 2005 聪聪&可可