杭电acm2024

第31行的getchar();如果写了就是WA,不写就是AC。

但是第九行的getchar();一定要写。

函数gets的原型为:char*gets(char*buffer); 

在 stdio.h中定义,如果要程序中用到此函数需包含#include<stdio.h>

gets()函数用来从标准输入设备(键盘)读取字符直至接受到换行符或EOF时停止结束,并将读取的结果存放在buffer指针所指向的字符数组中,但换行符会被丢弃,然后在末尾添加'\0'字符

The line consists of all characters up to and including the first newline character ('\n'). gets then replaces the newline character with a null character ('\0') before returning the line. In contrast, the fgets function retains the newline character. _getws is a wide-character version of gets; its argument and return value are wide-character strings.

-----from msdn

#include <stdio.h>
#include <ctype.h>

int main() {
	
	int n, i, flag;
	char s[50], c;
	while(~scanf("%d", &n)) {
		getchar();
		while(n--) {
			gets(s);
			
			
			if(s[0]!='_' && !isalpha(s[0])) {
				printf("no\n");
				continue;
			} 
			flag = 0;
			for(i=0; s[i]!='\0'; i++) {
				if(!isalpha(s[i]) && !isalnum(s[i]) && s[i]!='_') {
					flag = 1;
					break;
				}
					
			}
			if(flag)
				printf("no\n");
			else
				printf("yes\n");
			
		//	getchar();
		}
	}
	
	return 0;
}


转载于:https://www.cnblogs.com/StevenL/p/6818637.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值