数字提取——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;
}
数字提取——C语言的更多相关文章
- [原]Java面试题-将字符串中数字提取出来排序后输出
[Title][原]Java面试题-将字符串中数字提取出来排序后输出 [Date]2013-09-15 [Abstract]很简单的面试题,要求现场在纸上写出来. [Keywords]面试.Java. ...
- 提取字符串中的数字(C语言)
题目要求 问题描述:给定一个任意字符串,提取出其中所包含的整数. 样例输入:A12 32bc de51f6576g 样例输出:共计 4 个整数:12 32 51 6576 解决方案-指针版本 核心思想 ...
- 【总结】java regex 正则表达式 提取数字和去除数字,过滤数字,提取价格
@Test public void test33() { String phoneString = "哈哈,13888889999"; // 提取数字 Pattern patter ...
- 数字转汉字|语言代码|NSNumberFormatter
iOS之阿拉伯数字转中文数字 - 简书 iOS中金额数字的格式化 NSNumberFormatter - 简书 ISO语言代码(ISO-639)与国家代码(ISO-3166) - CSDN博客 语种名 ...
- PAT 1012 数字分类 C语言
给定一系列正整数,请按要求对数字进行分类,并输出以下5个数字: A1 = 能被5整除的数字中所有偶数的和: A2 = 将被5除后余1的数字按给出顺序进行交错求和,即计算n1-n2+n3-n4...: ...
- [LeetCode] 2. Add Two Numbers 两个数字相加 java语言实现 C++语言实现
[LeetCode] Add Two Numbers 两个数字相加 You are given two non-empty linked lists representing two non-ne ...
- 使用translate将字符串中的数字提取出来
--方法1: with tmp as ( select '按时的撒旦123元(其中含存款11元)' name from dual union all select '一类似的预存9600元(新势力)' ...
- 数字信号处理C语言集(1.1 随机数的产生)
main.cpp 所建工程文件如下图所示 uniform.h #ifndef _UNIFORM_H_ #define _UNIFORM_H_ double uniform(double a,doub ...
- php提取字符串中的数字
最近工作中写代码的时候需要在一串字符串中将所有的数字提取出来这么一个小功能,研究了一下发现方法还挺多,值得记录一下,于是对如何使用PHP将字符串中的数字提取出来的功能做了一个小总结,总结三种方法如下: ...
随机推荐
- ubuntu python3和python2切换脚本
最近在ubuntu上开发较多,有些工具只能在python2运行,而开发又是在python3上做的开发,所以写个脚本方便在python2和python3之间切换. 切换成python2的文件usepy2 ...
- map/reduce/filter/lambda
Python内建了map()/reduce()/filter()函数. map()函数接收两个参数,一个是函数,一个是Iterable,map将传入的函数依次作用到序列的每个元素,并把结果作为新的It ...
- leetcode习题练习
day001 #!user/bin/env python # -*- coding:utf-8 -*- #day001 两数之和 #方法1 def Sum(nbs,tgt): len_nums = l ...
- Failed to resolve: common Open File 导入项目问题
Failed to resolve: common Open File Warning:Configuration 'compile' is obsolete and has been replac ...
- docker 批量删除
杀死所有正在运行的容器docker kill $(docker ps -a -q) 删除所有已经停止的容器docker rm $(docker ps -a -q) 删除所有未打 dangling 标签 ...
- python http请求及多线程应用
目录 概述 tomorrow包准备 运行环境遇到的问题 其他尝试未果 概述 今天, 使用python3 模拟下发包, http get 请求, 然后 采用tomorrow 多线程. 代码如下: # c ...
- Getting started - RN1
0. down yarn https://yarnpkg.com 1. Expo Cli 此环境用于开发或学习之用. (1)install npm install -g expo-cli (2) us ...
- Java 多态的实现机制
http://my.oschina.net/onlytwo/blog/52222 是父类或接口定义的引用变量可以指向子类或实现类的实例对象,而程序调用的方法在运行期才动态绑定,就是引用变量所指向的具体 ...
- 【待考察】Appium使用技巧,助你快速入门移动端自动化!
Appium使用技巧,助你快速入门移动端自动化! 原创: 柠檬班superman 柠檬班软件测试 1月4日 关注并置顶[柠檬班]的小哥哥小姐姐 “猪”年行大运 说说最近研究移动端的自动化 移动端的自动 ...
- attr 和 prop 的区别
在高版本的jquery引入prop方法后,什么时候该用prop?什么时候用attr?它们两个之间有什么区别?这些问题就出现了. 关于它们两个的区别,网上的答案很多.这里谈谈我的心得,我的心得很简单: ...