只在本地跑过,不确保一定对
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#define setbit(value,bit) (value = value |(1<<bit))
int main(void)
{
char buf[201];
char out[201];
int i = 0;
int top = 0;
int len = 0;
bool bout = false;
int status=0;
while(1)
{
top = 0;
status = 0x00;
bout = false;
memset(buf,'\0',sizeof(buf));
gets(buf);
len = strlen(buf);//不包含最后结束符\0
for(i=0; i<len; i++)
{
if(buf[i] != '<')
{
out[top] = buf[i];
top++;
}
else
{
top--;//消掉栈顶
}
}
out[top] = '\0';
if(top>=8)
{
setbit(status,0);
for(i=0; i<top; i++)
{
if(out[i]>= 'A' && out[i]<='Z')
{
setbit(status,1);
printf("bit1\n");
}
else if(out[i]>= 'a' && out[i]<='z')
{
setbit(status,2);
printf("bit2\n");
}
else if(out[i]>= '0' && out[i]<='9')
{
setbit(status,3);
printf("bit3\n");
}
else if(out[i] > ' ' )//大于空格后面的字符都是特殊字符
{
setbit(status,4);
printf("bit4\n");
}
}
}
else
{
bout = false;
}
if((status & 0x1f) == 0x1f)
{
bout = true;
}
printf("%s,%d 0x%x\n",out,bout,status);
}
}