http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2971

题意:将输入的英文数字表达转化为阿拉伯数字。

 #include<bits/stdc++.h>
using namespace std; char aa[][]= {"zero", "one","two", "three", "four", "five", "six", "seven", "eight", "nine",
"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen","nineteen",
"twenty","thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"
};
int bb[]= {,,,,,,,,,,,,,,,,,,,,,,,,,,,};
char cc[][];
int main() {
int t;
char s[];
scanf("%d",&t);
getchar();//先吃掉t后面的回车
while(t--) {
memset(s,,sizeof(s));
memset(cc,,sizeof(cc));
gets(s);
int num=,k=;
int len=strlen(s);
for(int i=; i<len; i++) {
if(i>=&&s[i]==' '&&s[i-]!=' ') {
num++;//在’ ‘前算上一个字符串
k=;
continue;
}
if(s[i]!=' ')
cc[num][k++]=s[i];//装入一个字符串
}
int sum1=,sum2=;
int j;
        //有前至后读入字符串
for(int i=; i<=num; i++) {
for(j=; j<; j++) {
if(strcmp(cc[i],aa[j])==) {
sum1+=bb[j];
break;
}
}
if(j=) {
if(strcmp(cc[i],"and")==)
continue;
if(strcmp(cc[i],"thousand")==) {
sum1*=;
sum2+=sum1;
sum1=;
} else if(strcmp(cc[i],"hundred")==)
sum1*=;
else if(strcmp(cc[i],"million")==) {
sum1*=;
sum2+=sum1;
sum1=;
}
}
}
printf("%d\n",sum2+sum1);
}
return ;
}//善于使用strcmp函数,其实想到就很简单了

The 5th Zhejiang Provincial Collegiate Programming Contest---ProblemG:Give Me the Number的更多相关文章

  1. nenu contest3 The 5th Zhejiang Provincial Collegiate Programming Contest

    ZOJ Problem Set - 2965 Accurately Say "CocaCola"!  http://acm.zju.edu.cn/onlinejudge/showP ...

  2. zoj The 12th Zhejiang Provincial Collegiate Programming Contest May Day Holiday

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5500 The 12th Zhejiang Provincial ...

  3. 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(第二部分)

    Floor Function Time Limit: 10 Seconds      Memory Limit: 65536 KB a, b, c and d are all positive int ...

  4. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Capture the Flag

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5503 The 12th Zhejiang Provincial ...

  5. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Team Formation

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5494 The 12th Zhejiang Provincial ...

  6. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Beauty of Array

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5496 The 12th Zhejiang Provincial ...

  7. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Lunch Time

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5499 The 12th Zhejiang Provincial ...

  8. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Convert QWERTY to Dvorak

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5502  The 12th Zhejiang Provincial ...

  9. zoj The 12th Zhejiang Provincial Collegiate Programming Contest Demacia of the Ancients

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5504  The 12th Zhejiang Provincial ...

  10. zjuoj The 12th Zhejiang Provincial Collegiate Programming Contest Ace of Aces

    http://acm.zju.edu.cn/onlinejudge/showContestProblem.do?problemId=5493 The 12th Zhejiang Provincial ...

随机推荐

  1. Messenger实现Android IPC

    当Service不需要支持并发操作时Messenger会非常有用.Messenger类使用Handler执行每个传入的消息,所有客户端的调用都按顺序运行在同一个线程上,这和AIDL是有区别的,AIDL ...

  2. jquery学习--选择器

    选择器:basic $('button') html 标签 $('#test') 标签ID $('.test') 标签的class $('.test,#test,h1') 多选用逗号隔开 $('*') ...

  3. eclipse中英文切换--四种方式

    若转载,请注明出处 http://www.cnblogs.com/last_hunter/p/5627009.html 谢谢! ------------------------------------ ...

  4. info sed 中文不完全文档

    快速指南: sed 的一般使用方法:sed -option 'adress|command' -f scpritfiles(1)'|' 只是用来说明性的分隔 adress 和 command,实际使用 ...

  5. HDU 2340 Obfuscation(dp)

    题意:已知原串(长度为1~1000),它由多个单词组成,每个单词除了首尾字母,其余字母为乱序,且句子中无空格.给定n个互不相同的单词(1 <= n <= 10000),问是否能用这n个单词 ...

  6. DTCMS会员中心快速更改样式思路

    非常简便 制作一个public.css文件,包含网站头部和底部的样式代码 每个会员中心模版导入这个文件就可以 把原先style.css的头部和底部样式代码删除

  7. mvc的删除

    有UserInfo一个实体类,db代表请求上下文 属性有ID,UserName,UserPass,Email var users=from c in db.UserInfo select c; var ...

  8. 如何使用Git——(一)

    一.git与github git 是一款自由和开源的分布式版本控制系统,用于敏捷高效地处理任何或大或小的项目. github 是一个网站,给用户提供git仓库托管服务,是开源代码库以及版本控制系统.在 ...

  9. apache配置网站目录的读写权限

    分享下apache中配置网站目录文件权限的方法. 假设http服务器运行用户和用户组是www,网站用户为centos,网站根目录是/home/centos/web. 操作方法与步骤:1,首先,设定网站 ...

  10. NativeExcel 读取文件

    class function T_EShopDataBill.ImportData(const AFileName: String; AList: T_EShopDataModelList; var ...