POJ 1126 Simply Syntax 题解(gcc) - 哆啦比猫的技术瞎扯 - Arch Linux · ドラえもん · 实时绘制

POJ 1126 Simply Syntax 题解(gcc)

哆啦比猫 posted @ 2011年8月20日 11:38 in OI with tags OI POJ , 2157 阅读

http://poj.org/problem?id=1126  又一指针运用


#include <stdio.h>

char is_correct(char * s[]);

int main(void)
{
	char line[257];
	char * s;
	while (scanf("%256s", line) != EOF) {
		s = line;
		printf("%s\n", (is_correct(&s) && !s[1] ? "YES" : "NO"));
	}
	return 0;
}

char is_correct(char * s[])
{
	if (!**s) return 0;
	if (**s >= 'p' && **s <= 'z') return 1;
	if (**s == 'N') {
		++*s;
		return is_correct(s);
	}
	if (**s == 'C' || **s == 'D' || **s == 'E' || **s == 'I') {
		++*s;
		if (!is_correct(s)) return 0;
		++*s;
		return is_correct(s);
	}
	return 0;
}

凡未特殊声明(转载/翻译),所有文章均为原创。
by Giumo Xavier Clanjor (哆啦比猫/兰威举), 2010-2019.
知识共享许可协议本作品采用知识共享署名·非商业性使用·相同方式共享 3.0 中国大陆许可协议进行许可。
文中凡未特殊声明且未声明为引用的代码均以 MIT 协议授权。

blog comments powered by Disqus
© 2010-2019 Giumo Xavier Clanjor (哆啦比猫/兰威举).
© 2013, 2014, 2015-2016 and 2017 The Dark Colorscheme Designed by Giumo Xavier Clanjor (哆啦比猫/兰威举).
知识共享署名·非商业性使用·相同方式共享 3.0 中国大陆许可协议
| © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee