当前位置:网站首页>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;
}边栏推荐
- Lfi-rce without controllable documents
- KnightCTF WEB
- Minimum covering substring of two pointers
- Data recovery software easyrecovery15 Download
- Solve the problem that codeblocks20.03 on win11 cannot run for the first time
- Shangpinhui knowledge points of large e-commerce projects
- DR-TANet: Dynamic Receptive Temporal Attention Network for Street Scene Change Detection
- JS array
- How does hbuilder display in columns?
- For loop and promise to solve the problem of concurrent callback
猜你喜欢

CCF string matching (Full Score code + problem solving ideas + skill summary) March 3, 2014

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

2021-07-14 mybaitsplus

V3 03_ Getting started

Shangpinhui knowledge points of large e-commerce projects

day02

XSS challenge (6-10) more detailed answers

Clear the route cache in Vue

val_ Loss decreases first and then increases or does not decrease but only increases

KnightCTF WEB
随机推荐
DefCamp Capture the Flag (D-CTF) 2021-22 web
Three ways and differences of defining functions in JS
Clear the route cache in Vue
[extensive reading of papers] attributes guided facial image completion
Minimum covering substring of two pointers
[extensive reading of papers] a delicious recipe analysis framework for exploring multi modal recipes with variable attributes
Error $(...) size is not a function
CCF string matching (Full Score code + problem solving ideas + skill summary) March 3, 2014
How many questions can you answer for the interview of Mechanical Engineer?
Effect of shadow around the block after mouse over
CCF adjacent number pairs (Full Score code + problem solving ideas + skill summary) 201409-1
Programming of left-hand trapezoidal thread
val_ Loss decreases first and then increases or does not decrease but only increases
Win10 one click Reset win10 to solve all system bugs without deleting any files and Applications
Component communication mode
ThinkPHP show method parameter controllable command execution
这种零件该怎么编程加工?
CCF numerical sorting (Full Score code + problem solving ideas + skill summary) 201503-2
JS array sorting method summary
Double pointer letter matching