06: valid C identifier, 06 identifier

Source: Internet
Author: User

06: valid C identifier, 06 identifier
06: Legal C identifier

  • View
  • Submit
  • Statistics
  • Question
Total time limit:
1000 ms
Memory limit:
65536kB
Description

.

C language identifier requirements:

1. Non-reserved words;

2. Only letters, numbers, and underscores (_) are allowed.

3. Do not start with a number.

Input
A line that contains a string. The string does not contain any blank characters and cannot exceed 20 characters.
Output
A row. If it is a valid identifier of the C language, yes is output; otherwise, no is output.
Sample Input
RKPEGX9R;TWyYcp
Sample output
no
Source
Introduction to computing of Peking University 06 psychological and Information Management Final Examination
 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 char a[10001]; 6 int main() 7 { 8     gets(a); 9     int l=strlen(a);10     int flag=0;11     12         for(int i=0;i<l;i++)13         {    14         if(i==0)15             {16             if(a[0]>=48&&a[0]<=57)17                 {        18                     cout<<"no";19                     return 0;20                 }21             }22             if((a[i]==95)||(a[i]>=48&&a[i]<=57)||(a[i]>=65&&a[i]<=90)||(a[i]>=97&&a[i]<=122))23             flag=0;24             else flag=1;25             if(flag==1)26             {27                 cout<<"no";28                 return 0;29             }else continue;30         }31     32     cout<<"yes";33     return 0;34 }

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.