HDOJ 2024 C language legal identifiers (water questions, speaking identifiers)

Source: Internet
Author: User

C-Language legal identifiersTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others) Total Submission (s): 42681 Accepted Submission (s): 17117

Problem description Enter a string to determine whether it is a valid identifier for C.

Input data contains multiple test instances, the first row of the data is an integer n, which indicates the number of test instances, followed by n rows of input data, each of which is a string of not more than 50 in length.

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

Sample Input
312ajffi8x_aff  ai_2

Sample Output
Noyesno

problem : The topic is very simple, no difficulty and skill. Focus on the C language legal identifiers . definition: In the high-level computer language, the valid character sequences used to name variables, symbolic constant names, functions, arrays, types, etc. are collectively referred to as identifiers.    Note: 1. The C language specifies that identifiers can only consist of letters, numbers, and underscores of 3 characters, and that the 1th character must be a letter or an underscore. 2. The compilation system considers uppercase and lowercase letters to be two different characters.
The AC code is as follows:
#include <stdio.h> #include <string.h>int main () {int Len,n,i;char str[55];scanf ("%d", &n); GetChar (); /here to absorb character while (n--) {gets (str); if (str[0]<65| | str[0]>122) &&str[0]!= ' _ ')  printf ("no\n"); else{  int K=0;len=strlen (str); for (i=1;i<len;i++) {if (str[i]<48| | (str[i]<65&&str[i]>57) | | str[i]>122) &&str[i]!= ' _ ') {K=1;break;}} if (!k)  printf ("yes\n"), Else      printf ("no\n");}} return 0;}


HDOJ 2024 C language legal identifiers (water questions, speaking identifiers)

Related Article

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.