博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sdut 2163:Identifiers(第二届山东省省赛原题,水题)
阅读量:6168 次
发布时间:2019-06-21

本文共 2066 字,大约阅读时间需要 6 分钟。

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.

示例输入

7ValidIdentifiervalid_identifiervalid_identifier0_invalid_identifier1234567invalid identifieradefhklmruvwxyz12356790_-.,:;!?'"()[]ABCDGIJLMQRSTVWXYZ

示例输出

YesYesYesNoNoNoNo

提示

 

来源

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

 
  水题
  代码:
1 #include 
2 #include
3 using namespace std; 4 5 int main() 6 { 7 int i,j,n; 8 cin>>n; 9 getchar();10 for(i=1;i<=n;i++){11 char a[110];12 cin.getline(a,110,'\n');13 if(('a'<=a[0] && a[0]<='z') || ('A'<=a[0] && a[0]<='Z') || a[0]=='_'){14 for(j=0;a[j];j++)15 if(!(('a'<=a[j] && a[j]<='z') ||16 ('A'<=a[j] && a[j]<='Z') ||17 ('0'<=a[j] && a[j]<='9') ||18 a[j]=='_') )19 break;20 if(a[j])21 cout<<"No"<

 

Freecode :

转载地址:http://wgcba.baihongyu.com/

你可能感兴趣的文章
Mapreduce 扫描hbase表建立solr索引
查看>>
RHEL 5.8 yum本地源
查看>>
Teams 新功能更新【五月底】Busy on Busy 忙线音
查看>>
orzdba安装与使用
查看>>
二叉搜索树的插入叶子结点的递归实现方法
查看>>
通过nginx配置不同二级域名代理多个系统
查看>>
linux基础篇-23,文件系统管理
查看>>
keepalived+nginx高可用配置
查看>>
node.js爬虫爬取电影天堂,实现电视剧批量下载。
查看>>
Ubuntu 18.04.1 LTS下部署FastDFS 5.11+Nginx 1.14.0
查看>>
PHP 运行方式(PHP SAPI介绍)
查看>>
puppet学习之puppet证书验证
查看>>
Server 2008 R2 AD RMS完整部署:四、客户端篇
查看>>
Alcatel-Lucent 7750 运营商认证设备在线用户数OID
查看>>
靠自己。linux manul手册入门
查看>>
思科设备中查询筛选的命令精华
查看>>
大数据未来将呈现的八大发展趋势
查看>>
cm 升级
查看>>
创建数据库快照并恢复数据
查看>>
我的友情链接
查看>>