数字提取——C语言

Problem Description
AekdyCoin is the most powerful boy in the group ACM_DIY, whose signature is valuable. In order to get his signature, you must first solve this problem. But don't be worried, because this is the easiest problem in the world. You are given only one sentence written in English. You are asked to output a single integer implied by this sentence.

Input
There is only one line in the input. It is a sentence which implies some integer. The length of the sentence is no more than 16. The sentence contains only letters(both uppercase and lowercase), digits, and whitespace. You may assume the given sentence is written in standard English, and always implies exactly one single integer.

Output
There is only one integer to output: that is the integer implied by the input sentence. You may assume this integer is in the range of 32-bit signed int.

Sample Input
One

Sample Output
1

AekdyCoin是ACM_DIY组合中实力最强的男孩,他的签名很有价值。为了得到他的签名,你必须先解决这个问题。但是不要担心,因为这是世界上最容易的问题。只给你一个用英语写的句子。要求您输出这个句子所隐含的单个整数。

输入

输入中只有一行。这是一个含有整数的句子。句子的长度不超过16。这个句子只包含字母(大写和小写)、数字和空格。您可以假设给定的句子是用标准英语编写的,并且总是暗示只有一个整数。

输出

输出只有一个整数:这是输入语句隐含的整数。您可以假设这个整数的范围是32位有符号整型。

样例输入

一个

样例输出

1

#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	string str;
	string number[10] = { "zero","one","two","three","four","five","six","seven","eight","nine" };
	cin >> str;
	transform(str.begin(), str.end(), str.begin(), ::tolower);
	for (int i = 0; i < 10; i++) {
		if (str.find(number[i]) != string::npos) {
			cout << i;
			break;
		}
	}
	return 0;
}

 

转载于:https://www.cnblogs.com/F-itachi/p/9974334.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值