杭电 2024


 1 #include <iostream>
2 #include <string>
3 using namespace std;
4
5 int main()
6 {
7 int n;
8 string str;
9 int flag;
10 while (cin>>n)
11 {
12 cin.get();// 上一行的处理回车
13 for (int i=0; i<n; i++)
14 {
15
16 getline(cin,str);
17 // cin>> str;
18
19 flag = 1;
20 for (int i=0; i<str.length();i++)
21 {
22 if (!(isdigit(str[i])||isalpha(str[i])|| str[i]==‘_‘))
23 {
24 flag = 0;
25 }
26 }
27 if (isdigit(str[0]))
28 {
29 flag = 0;
30 }
31 if (!flag)
32 {
33 cout<<"no"<<endl;
34 }
35 else
36 {
37 cout<<"yes"<<endl;
38 }
39 }
40 }
41 return 0;
42 }

杭电 2024

时间: 2024-10-12 20:30:16

杭电 2024的相关文章

杭电2024(C语言合法标识符)

杭电2024 Problem Description 输入一个字符串,判断其是否是C的合法标识符. Input 输入数据包含多个测试实例,数据的第一行是一个整数n,表示测试实例的个数,然后是n行输入数据,每行是一个长度不超过50的字符串. Output 对于每组输入数据,输出一行.如果输入数据是C的合法标识符,则输出"yes",否则,输出"no". Sample Input 3 12ajf fi8x_a ff ai_2 Sample Output no yes no

杭电2024

1 #include<stdio.h> 2 char s[51]; 3 int lenth(char s[]) 4 { 5 int i=0; 6 while(s[i]) 7 ++i; 8 return i; 9 } 10 int main() 11 { 12 int i,n; 13 while(~scanf("%d",&n)) 14 { 15 getchar(); 16 while(n--) 17 { 18 gets(s); 19 int len=lenth(s);

C语言合法标识符 【杭电-2024】 附题

/* C语言合法标识符 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 35717    Accepted Submission(s): 14361 Problem Description 输入一个字符串,判断其是否是C的合法标识符. Input 输入数据包含多个测试实例,数据的第一行是一个整数n,表示测试实例的个数,然后是n行输入数据

杭电ACM题目分类

杭电ACM题目分类 基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028. 1029.1032.1037.1040.1048.1056.1058.1061.1070.1076.1089.1090.1091.1092. 1093.1094.1095.1096.1097.1098.1106.1108.1157.1163.1164.1170.1194.1196. 1197.1201.1202.1205.1219.1234.123

杭电 HDU 1164 Eddy&#39;s research I

Eddy's research I Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 7117    Accepted Submission(s): 4268 Problem Description Eddy's interest is very extensive, recently  he is interested in prime

hdu 1016 Prime Ring Problem DFS解法 纪念我在杭电的第一百题

Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 29577    Accepted Submission(s): 13188 Problem Description A ring is compose of n circles as shown in diagram. Put natural num

杭电ACM分类

杭电ACM分类: 1001 整数求和 水题1002 C语言实验题——两个数比较 水题1003 1.2.3.4.5... 简单题1004 渊子赛马 排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想 数论:容斥定理1007 童年生活二三事 递推题1008 University 简单hash1009 目标柏林 简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 IMMEDIATE DECODABILITY

一个人的旅行 HDU杭电2066【dijkstra算法】

http://acm.hdu.edu.cn/showproblem.php?pid=2066 Problem Description 虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能丰富自己的阅历,还可以看美丽的风景--草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去阳明山上看海芋,去纽约纯粹看雪景,去巴黎喝咖啡写信,去北京探望孟姜女--眼看寒假就快到了,这么一大段时间,可不

杭电1162--Eddy&#39;s picture(Prim()算法)

Eddy's picture Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8070    Accepted Submission(s): 4084 Problem Description Eddy begins to like painting pictures recently ,he is sure of himself to b