当前位置:网站首页>1134: Legal C identifier query
1134: Legal C identifier query
2022-06-30 14:49:00 【I would, I think】
Method 1 : Write directly according to the meaning of the title , Easy to understand
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
char a[300];
cin.getline(a,300);
int len=strlen(a);
if(a[0]>='0'&&a[0]<='9')
{
cout<<"no";
return 0;
}
for(int i=0;i<len;i++)
{
if(((a[i]>='0'&&a[i]<='9')||(a[i]>=65&&a[i]<=90)||(a[i]>=97&&a[i]<=122)||a[i]=='_'))
{
;
}
else
{
cout<<"no";
return 0;
}
}
cout<<"yes";
return 0;
}Method 2 : Similar to method 1
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
char a[300];
cin.getline(a,300);
int len=strlen(a);
if(a[0]>='0'&&a[0]<='9')
{
cout<<"no";
return 0;
}
for(int i=0;i<len;i++)
{
if(!((a[i]>='0'&&a[i]<='9')||(a[i]>=65&&a[i]<=90)||(a[i]>=97&&a[i]<=122)||a[i]=='_'))
{
cout<<"no";
return 0;
}
}
cout<<"yes";
return 0;
}Method 3 : Do not convert letters to asscii The corresponding number in
#include<string.h>
#include<iostream>
using namespace std;
int main()
{
char a[300];
cin.getline(a,300);
int len=strlen(a);
if(a[0]>='0'&&a[0]<='9')
{
cout<<"no";
return 0;
}
for(int i=0;i<len;i++)
{
if(((a[i]>='0'&&a[i]<='9')||(a[i]>='A'&&a[i]<='Z')||(a[i]>='a'&&a[i]<='z')||a[i]=='_'))
{
;
}
else
{
cout<<"no";
return 0;
}
}
cout<<"yes";
return 0;
}边栏推荐
- Add attributes to multimode
- The difference between settimeout() and setinterval()
- C language & the difference between the address pointed to and the address pointed to by the pointer
- 文本匹配——【NAACL 2022】GPL
- Summary of use of laravel DCAT admin
- Searching for single element in dichotomy
- August 24, 2021 deque queue and stack
- PHP conditional operator
- 2021-08-07 native and package types
- How does hbuilder display in columns?
猜你喜欢

KnightCTF WEB

Summary of use of laravel DCAT admin
![【BUUCTF】[GXYCTF2019]Ping Ping Ping1](/img/dc/4d87dfb0c2fa9cd75b54e092fd3971.jpg)
【BUUCTF】[GXYCTF2019]Ping Ping Ping1

Knowledge learned from the water resources institute project

After the MySQL service on the local computer is started and stopped, some services will automatically stop when they are not used by other services or programs

PS cutting height 1px, Y-axis tiling background image problem

PS dynamic drawing

Solve the problem that codeblocks20.03 on win11 cannot run for the first time

On simple code crawling Youdao translation_ 0's problem (to be solved)

Using docker to manage MySQL services under Windows
随机推荐
CCF sequence segmentation (Full Score code + problem solving idea) 201509 -1
[buuctf] [actf2020 freshman competition]include
浅析卧式加工中心上不规则台阶孔存在问题
Sum of squares of two pointers
[buuctf] [actf2020 freshman competition]exec1
立式加工中心调试的步骤
数控加工中心打刀缸工作原理及故障处理
[extensive reading of papers] multimodal attribute extraction
jsPlumb. Deleteeveryconnection is not a function & jsplumb clear canvas jsplumb delete all nodes and all connections
For loop and promise to solve the problem of concurrent callback
DB2 SQL Error: SQLCODE=-206, SQLSTATE=42703
Lfi-rce without controllable documents
Binary rotation array (1)
In situ merging of two arrays with two pointers
Pseudocode writing specification
org. json. The jsonobject object is converted to JSON, and JSON adds new elements. The value is obtained according to the JSON key. And list object format string to jsonarray
Thinkphp5 log file contains trick
MV3 04_ Introducing Manifest V3
V3_ Chrome extended Chinese translation document V3 directory
@PathVariable