UVA Solution 384 - Slurpys - Solution in C, C++ | Volume 3
UVA Online Judge Solution 384 - Slurpys | Volume 3
UVA Problem Link - https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=5&page=show_problem&problem=320
Problem Name: 384 - Slurpys
Problem Number : UVA - 384 - Slurpys
Online Judge : UVA Online Judge Solution
Volume: 3
Solution Language : C, C plus plus
UVA Solution 384 - Slurpys Code in C, CPP:
#include <stdio.h> char s[1005], *p; int Slump() { if(*p != 'D' && *p != 'E') return 0; p++; if(*p != 'F') return 0; while(*p == 'F') p++; if(*p == 'G') { p++; return 1; } return Slump(); } int Slimp() { if(*p != 'A') return 0; p++; if(*p == 'H') { p++; return 1; } if(*p == 'B') { p++; bool flag = Slimp() && *p == 'C'; p++; return flag; } bool flag = Slump() && *p == 'C'; p++; return flag; } int main() { int t; scanf("%d", &t); puts("SLURPYS OUTPUT"); while(t--) { scanf("%s", s); p = s; bool flag = Slimp() && Slump() && *p == '\0'; puts(flag ? "YES" : "NO"); } puts("END OF OUTPUT"); return 0; }
No comments:
Post a Comment