HDOJ 2024 legal identifier of C language (water question, talk about identifier)

Source: Internet
Author: User

HDOJ 2024 legal identifier of C language (water question, talk about identifier)
C Legal identifier Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission (s): 42681 Accepted Submission (s): 17117

Problem Description input a string to determine whether it is a legal identifier of C.

The Input data contains multiple test instances. The first line of the data is an integer n, indicating the number of test instances, followed by n rows of Input data, each line is a string of no more than 50 characters.

Output outputs a row of input data for each group. If the input data is a valid identifier of C, "yes" is output; otherwise, "no" is output ".

Sample Input

312ajffi8x_aff  ai_2

Sample Output
noyesno

Question: The question is very simple and there is no difficulty or skill. It focuses on the legal identifier of the C language. Definition: in advanced computer languages, effective character sequences used for naming variables, symbolic constant names, functions, arrays, and types are collectively referred to as identifiers. Note: 1. the C language specifies that an identifier can only contain letters, numbers, and underscores (_), and must contain letters or underscores. 2. the compiling system considers uppercase letters and lowercase letters as two different characters.
The AC code is as follows:
# Include
 
  
# Include
  
   
Int main () {int len, n, I; char str [55]; scanf ("% d", & n); getchar (); // The while (n --) {gets (str); if (str [0] <65 | str [0]> 122) characters must be absorbed here) & str [0]! = '_') Printf ("no \ n"); else {int k = 0; len = strlen (str); for (I = 1; I
   
    
57) | str [I]> 122) & str [I]! = '_') {K = 1; break;} if (! K) printf ("yes \ n"); else printf ("no \ n") ;}} return 0 ;}
   
  
 


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.