ACM ICPC East Central North America 1994_Simply Syntax
来源:互联网 发布:vm安装mac 编辑:程序博客网 时间:2024/05/18 00:08
写这篇博客,主要是贴一段代码。该代码用于解决哈尔滨工业大学(我的母校)acm上的一道题目。闲话少叙:
代码中含有题目要求,代码如下:
/* Author : Li Pan Date : 2013/2/25 Function : A program to solve an acm program named Simply Syntax. Its requirements is as follows : 0. The only characters in the language are the characters p through z and N, C, D, E, and I. 1. Every character from p through z is a correct sentence. 2. If s is a correct sentence, then so is Ns. 3. If s and t are correct sentences, then so are Cst, Dst, Est, and Ist. 4. Rules 0. to 3. are the only rules to determine the syntactical correctness of a sentence. */#include <stdio.h>char test_string[1024];char yes_or_no;int get_last_index_of_sentence(int start) { char current_char; int last_index; int temp_index; if (start >= strlen(test_string)) {last_index = -1;return last_index; } current_char = test_string[start]; switch(current_char) { case 'p' : case 'q' : case 'r' : case 's' : case 't' : case 'u' : case 'v' : case 'w' : case 'x' : case 'y' : case 'z' : last_index = start;break;case 'N' : last_index = get_last_index_of_sentence(start + 1);break;case 'C' : case 'D' : case 'E' : case 'I' :temp_index = get_last_index_of_sentence(start + 1);last_index = get_last_index_of_sentence(temp_index + 1);break;default : /*very important for forbidden characters.*/last_index = -1;break; } return last_index;}int main() {int i;int last_index;fscanf(stdin, "%s", test_string);last_index = get_last_index_of_sentence(0);if (-1 == last_index)fprintf(stdout, "no\n");else if (last_index < strlen(test_string) - 1)fprintf(stdout, "no\n");else fprintf(stdout, "yes\n");return 0;}
- ACM ICPC East Central North America 1994_Simply Syntax
- 2012-2013 ACM-ICPC East Central North America Regional Contest (ECNA 2012)
- 2014-2015 ACM-ICPC East Central North America Regional Contest (ECNA 2014)
- 2005-2006 ACM-ICPC East Central North America Regional Contest (ECNA 2005) H.Two Ends
- 2005-2006 ACM-ICPC East Central North America Regional Contest (ECNA 2005) G.Swamp Things
- 2005-2006 ACM-ICPC East Central North America Regional Contest (ECNA 2005) F.Square Count
- East Central North America 2006
- East Central North America 1999 "Gone Fishing"
- East Central North America 2004 I Conduit!
- North America - East Central NA 2013
- North America - East Central NA 2012
- 130825组队赛-Regionals 2012, North America - East Central NA
- POJ 1028 / East Central North America 2001 Web Navigation (栈)
- 20131004组队赛-Regionals 2010, North America - East Central NA
- 组队赛131004 Regionals 2010, North America - East Central NA
- hdu 1063 Exponentiatio(East Central North America 1988)
- 【poj 1502】 MPI Maelstrom 【East Central North America 1996】
- POJ 1016 测试数据( East Central North America 1998 Numbers That Count Test data )
- 关于rtmp封包中数据类型为0x16的封包
- 如果你准备在2013奋斗,请好好研究这些铁律
- 利润大幅下滑:安卓2012运势如何
- PHP开发tips
- FreeMarker相关学习内容
- ACM ICPC East Central North America 1994_Simply Syntax
- CDT 8.0.2 for Eclipse Indigo
- 使用Java实现MP3音乐播放器
- listview用法2
- PHP AES
- android中图片上传使用http协议
- oracle crs起停步骤及srvctl crsctl 命令用法 分类: 借鉴参考
- ubuntu unity 后提示背景前景色的修改方法
- shell语法简介