Identifiers

Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^

题目描述

 Identifier is an important concept in the C programming language. Identifiers provide names for several language elements, such as functions, variables, labels, etc.

An identifier is a sequence of characters. A valid identifier can contain only upper and lower case alphabetic characters, underscore and digits, and must begin with an alphabetic character or an underscore. Given a list of chararcter sequences, write a program to check if they are valid identifiers.

输入

 The first line of the input contains one integer, N, indicating the number of strings in the input. N lines follow, each of which contains at least one and no more than 100 characters. (only upper and lower case alphabetic characters, digits, underscore (" "), hyphen ("-"), period ("."), comma (","), colon (":"), semicolon (";"), exclamation mark ("!"), question mark ("?"), single and double quotation marks, parentheses, white space and square brackets may appear in the character sequences.)

输出

For each of the N lines, output "Yes" (without quote marks) if the character sequence contained in that line make a valid identifier; output "No" (without quote marks) otherwise.

示例输入

7
ValidIdentifier
valid_identifier
valid_identifier
0_invalid_identifier
1234567
invalid identifier
adefhklmruvwxyz12356790_-.,:;!?'"()[]ABCDGIJLMQRSTVWXYZ

示例输出

Yes
Yes
Yes
No
No
No
No

提示

 

来源

山东省第二届ACM大学生程序设计竞赛

 
  水题
  代码:
 #include <iostream>
#include <stdio.h>
using namespace std; int main()
{
int i,j,n;
cin>>n;
getchar();
for(i=;i<=n;i++){
char a[];
cin.getline(a,,'\n');
if(('a'<=a[] && a[]<='z') || ('A'<=a[] && a[]<='Z') || a[]=='_'){
for(j=;a[j];j++)
if(!(('a'<=a[j] && a[j]<='z') ||
('A'<=a[j] && a[j]<='Z') ||
(''<=a[j] && a[j]<='') ||
a[j]=='_') )
break;
if(a[j])
cout<<"No"<<endl;
else
cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;
}
return ;
} /**************************************
Problem id : SDUT OJ 2163
User name : Miracle
Result : Accepted
Take Memory : 452K
Take Time : 0MS
Submit Time : 2014-04-20 09:18:49
**************************************/

Freecode : www.cnblogs.com/yym2013

sdut 2163:Identifiers(第二届山东省省赛原题,水题)的更多相关文章

  1. sdut 2162:The Android University ACM Team Selection Contest(第二届山东省省赛原题,模拟题)

    The Android University ACM Team Selection Contest Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里 ...

  2. sdut 2165:Crack Mathmen(第二届山东省省赛原题,数论)

    Crack Mathmen Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述  Since mathmen take securit ...

  3. sdut 2154:Shopping(第一届山东省省赛原题,水题)

    Shopping Time Limit: 1000MS Memory limit: 65536K 题目描述 Saya and Kudo go shopping together.You can ass ...

  4. sdut 2152:Balloons(第一届山东省省赛原题,DFS搜索)

    Balloons Time Limit: 1000MS Memory limit: 65536K 题目描述 Both Saya and Kudo like balloons. One day, the ...

  5. sdut 2159:Ivan comes again!(第一届山东省省赛原题,STL之set使用)

    Ivan comes again! Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 The Fairy Ivan gave Say ...

  6. sdut 2153:Clockwise(第一届山东省省赛原题,计算几何+DP)

    Clockwise Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Saya have a long necklace with ...

  7. sdut 2158:Hello World!(第一届山东省省赛原题,水题,穷举)

    Hello World! Time Limit: 1000MS Memory limit: 65536K 题目描述 We know that Ivan gives Saya three problem ...

  8. i春秋第二届春秋欢乐赛RSA256writeup

    i春秋第二届春秋欢乐赛writeup 下载之后进行解压 发现四个文件 0x01看到题目是RSA的  又看到public.key 所以直接用kali linux的openssl 0x02可以看到e就是E ...

  9. sdut 2603:Rescue The Princess(第四届山东省省赛原题,计算几何,向量旋转 + 向量交点)

    Rescue The Princess Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Several days ago, a b ...

随机推荐

  1. Win7下JDK环境变量的设置

    JDK并不像Microsoft阵营vs那样智能,安装好后所有的东西都给你配置好了,我们还没需要手动配置很多东西 首先说为什么要配置JDK的环境变量在任何路径下识别java命令和java类 配置分为2个 ...

  2. truncate的用法

    truncate是文件处理中的截断函数,今天是有个需求改动了json中的某个值,然后用改动后的值去覆盖之前的数据,这个方法有很多,比如边读边写,然后使用os模块替换,这个适合用于在程序和文件都在同一个 ...

  3. WinForm中动态添加控件 出现事件混乱,解决办法记录。

    还是在抢票软件中出的问题,我没点击一个联系人,要生成一排控件,其中有席别combobox这样的下拉框控件,会出现如下图所示的问题:问题描述:在代码中动态创建的控件,事件混乱了,一个控件触发了所有同类型 ...

  4. GIT本地操作

    01. GIT简介(PPT) ================================================================================ 02. ...

  5. UIScrollview自动布局,UIScrollviewAutolayoutDemo

    参考文档:http://www.cocoachina.com/ios/20150104/10810.html UIScrollviewAutolayoutDemo地址:http://pan.baidu ...

  6. redis设置密码和主从复制

    redis设置连接密码: 因为redis的速度相当的快,在一台比较好的服务器下,每秒可进行150K次密码尝试,所以要设置个非常强大的密码. 设置方式:修改配置文件redis.conf #require ...

  7. Java Socket发送与接收HTTP消息简单实现

    在上次Java Socket现实简单的HTTP服务我 们实现了简单的HTTP服务,它可以用来模拟HTTP服务,用它可以截获HTTP请求的原始码流,让我们很清楚的了解到我们向服务发的HTTP消息的结 构 ...

  8. java调用本地方法的时候报错 could not find the main class:xx.program will exit

    如图所示,当在java调用本地方法的时候报错 我的解决办法是把dll文件放到System.out.println(System.getProperty("java.library.path& ...

  9. JQUERY 模糊选择

    JQUERY 模糊选择        [属性名称]         匹配包含给定属性的元素      [att=value]       匹配包含给定属性的元素      [att*=value]   ...

  10. ubuntu 14.04 安装mysql server初级教程

    序,mysql数据库是开源的,被大多数企业所使用 目录 一.apt-get install 软件安装原理剖析二.安装mysql server三.配置和管理msyql 一.apt-get install ...