C 语言编程 字符串正逆对应 !!急需!!

来源:百度知道 编辑:UC知道 时间:2024/09/24 15:48:38
Regular expressions are one of the most broadly applicable specialized languages, a compact and expressive notation for describing patterns of text. Regular expressions are algorithmically interesting, easy to implement in their simpler forms, and very useful.

A regular expression is a sequence of characters that defines a pattern. Most characters in the pattern simply match themselves in a target string, so the regular expression "abc" matches that sequence of three letters wherever it occurs in the target. A few characters are used in patterns as metacharacters to indicate repetition, grouping, or positioning. In POSIX regular expressions, "^" stands for the beginning of a string and "$" for the end, so "^x" matches an "x" only at the beginning of a string, "x$" matches an "x" only at the end, "^x$" matches "x" only if it is the sole character of the string, and "^$" matches

ACM风格的题目,在VC++环境下使用C编译器现场给你写的程序,15分钟搞定,调试通过,没有问题。
按照题目要求,使用命令行参数。
注释就没有加了,认真看应该能看懂

#include "stdio.h"
#include "string.h"

int check(char*,char*);
int modeLeft(char*,char*);
int modeSub(char*,char*);
int modeRight(char*,char*);
int modeTight(char*,char*);
void reverseStr(char*);

void main(int argc,char** args)
{
if(argc!=3)
{
printf("command line arguments format:[sample string] [regular expression]\n");
return;
}
if(strlen(args[1])==0 || strlen(args[2])==0)
{
printf("command line arguments format:[sample string] [regular expression]\n");
return;
}
if(check(args[1],args[2])==0)
printf("lost");
else
printf("hit");

}

int check(char* str,char* res)
{
char head,tail;
head=res[0];
tail=res[strlen(res)-1];