C-Language legal 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): 39100 Accepted Submission (s): 15614


problem Descriptionenter a string to determine whether it is a valid identifier for C.

InputThe input data contains multiple test instances, and the first row of the data is an integer n, representing the number of test instances, followed by n rows of input data, each of which is a string of no more than 50 length.

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

Sample Input
312ajffi8x_aff  ai_2

Sample Output
Noyesnoproblem-solving ideas:isalpha function Link: http://blog.163.com/caipeipei_love%40126/blog/static/25966032201032784630227/ isalnum function Link: http://see.xidian.edu.cn/cpp/html/112.html        Source code:#include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h>int main () {  int i,n,f;  Char str[51];   scanf ("%d", &n);  GetChar ();    while (n--) {gets (str);    f=1;     if (str[0]!= ' _ ' &&!isalpha (Str[0])) f=0;    I=1;      while (str[i]!= ' && f==1) {if (str[i]!= ' _ ' &&!isalnum (Str[i])) f=0;                       i++;    } if (f==0) printf ("no\n");  else printf ("yes\n");    } system ("Pause");      return 0; }

C-Language legal 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.