【水字符操作】#46 A. Sleuth

A. Sleuth
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a "crime" and find out what is happening. He can ask any questions whatsoever that can be answered with "Yes" or "No". All the rest agree beforehand to answer the questions like that: if the question’s last letter is a vowel, they answer "Yes" and if the last letter is a consonant, they answer "No". Of course, the sleuth knows nothing about it and his task is to understand that.

Unfortunately, Vasya is not very smart. After 5 hours of endless stupid questions everybody except Vasya got bored. That’s why Vasya’s friends ask you to write a program that would give answers instead of them.

The English alphabet vowels are: A, E, I, O, U, Y

The English alphabet consonants are: B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Z

Input

The single line contains a question represented by a non-empty line consisting of large and small Latin letters, spaces and a question mark. The line length does not exceed 100. It is guaranteed that the question mark occurs exactly once in the line — as the last symbol and that the line contains at least one letter.

Output

Print answer for the question in a single line: YES if the answer is "Yes", NO if the answer is "No".

Remember that in the reply to the question the last letter, not the last character counts. I. e. the spaces and the question mark do not count as letters.

Sample test(s)
input
Is it a melon?
output
NO
input
Is it an apple?
output
YES
input
  Is     it a banana ?
output
YES
input
Is   it an apple  and a  banana   simultaneouSLY?
output
YES

这道题是说给你一个字符串,问你结尾的那个字符是不是元音或者半元音(A、E、I、O、U、Y)

所以我们每次读入一行(getline),然后从后往前数找到第一个是字母的字符(isupper()||islower()),然后看看它是不是这六个之一,为了省去大小写的问题,我们直接使用toupper把它变成大写,方便比对。

Code:

#include <queue>
#include <cmath> 
#include <memory> 
#include <cctype>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
char vwl[]={'A','E','I','O','U','Y'};
int main()
{
	int index; 
	string str;
	getline(cin,str);
	for(int i=str.length()-1;i>=0;i--)
	{
		if(isupper(str[i])||islower(str[i]))	
		{
			index=i;
			break;
		}
	}
	for(int i=0;i<6;i++) 
	if(toupper(str[index])==vwl[i])
	{
		cout<<"YES"<<endl;
		return 0;
	}
	cout<<"NO"<<endl;
	return 0;
}





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
这个报错信息表明您的应用程序中存在循环依赖的问题,具体来说,是TraceWebServletAutoConfiguration类中的traceWebFilter和tracingFilter相互依赖,导致了这个循环依赖的问题。 解决这个问题的方法是,您可以尝试升级Spring Cloud Sleuth的版本,以最新版本为例。如果您正在使用Spring Boot 2.4及以上版本,则可以将Spring Cloud Sleuth的版本升级到3.0及以上版本。在新版本中,已经解决了这个循环依赖的问题。 如果您不能升级到最新版本,您可以尝试手动配置TraceWebServletAutoConfiguration类中的traceWebFilter和tracingFilter的依赖关系,以避免循环依赖的问题。 具体来说,您可以在您的应用程序中创建一个新的bean,将这两个过滤器的依赖关系注入其中,然后将该bean注入到TraceWebServletAutoConfiguration类中,以解决循环依赖的问题。示例代码如下: ``` @Bean public FilterRegistrationBean<TraceWebFilter> traceWebFilterRegistration( TraceWebFilter traceWebFilter, TracingFilter tracingFilter) { FilterRegistrationBean<TraceWebFilter> registration = new FilterRegistrationBean<>(); registration.setFilter(traceWebFilter); registration.setOrder(Ordered.HIGHEST_PRECEDENCE); registration.addUrlPatterns("/*"); registration.setName("traceWebFilter"); registration.setAsyncSupported(true); registration.setDispatcherTypes( DispatcherType.REQUEST, DispatcherType.ASYNC, DispatcherType.ERROR); tracingFilter.setTracing(traceWebFilter.tracing()); return registration; } ``` 希望这些信息可以帮助您解决问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

糖果天王

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值