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. C#面向对象中类的静态成员与非静态成员的区别

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  2. std::auto_ptr

    auto_ptr是C++标准库中(<utility>)为了解决资源泄漏的问题提供的一个智能指针类模板(注意:这只是一种简单的智能指针) auto_ptr的实现原理其实就是RAII,在构造的 ...

  3. FITTING A MODEL VIA CLOSED-FORM EQUATIONS VS. GRADIENT DESCENT VS STOCHASTIC GRADIENT DESCENT VS MINI-BATCH LEARNING. WHAT IS THE DIFFERENCE?

    FITTING A MODEL VIA CLOSED-FORM EQUATIONS VS. GRADIENT DESCENT VS STOCHASTIC GRADIENT DESCENT VS MIN ...

  4. ON THE EVOLUTION OF MACHINE LEARNING: FROM LINEAR MODELS TO NEURAL NETWORKS

    ON THE EVOLUTION OF MACHINE LEARNING: FROM LINEAR MODELS TO NEURAL NETWORKS We recently interviewed ...

  5. WAF绕过的技巧

    研究过国内外的waf.分享一些绝技. 一些大家都了解的技巧如:/*!*/,SELECT[0x09,0x0A-0x0D,0x20,0xA0]xx FROM 不再重新提及. 以下以Mysql为例讲述这些技 ...

  6. IE浏览器模式设置

    文件兼容性用于定义让IE如何编译你的网页.此文件解释文件兼容性,如何指定你网站的文件兼容性模式以及如何判断一个网页该使用的文件模式. 前言 为了帮助确保你的网页在所有未来的IE版本都有一致的外观,IE ...

  7. MySQL获取随机数

    如何通过MySQL在某个数据区间获取随机数? MySQL本身提供一个叫rand的函数,返回的v范围为0 <= v < 1.0. 介绍此函数的MySQL文档也介绍道,可以通过此计算公式FLO ...

  8. word表格断行的问题

    word一个表格如果某一行的 内容 太多,就会自动跑到下一页去了 解决方法是: 在表格上点右键-> 属性 -> "行" -> 去掉"设置行高" ...

  9. js获取单选框里面的值

    rt,如果想获取单选框里面的值,该如何获取呢. <script> window.onload = function(){ //通过名字获取 getElementsByName //var ...

  10. Entity Framework 自动生成CodeFirst代码

    前言 在前面的文章中我们提到Entity Framework的“Code First”模式也同样可以基于现有数据库进行开发.今天就让我们一起看一下使用Entity Framework Power To ...