请问主函数中没有printf("",a)后面的语句是不执行还是什么情况,没有输出;以及actlist函数写错了,如果遇到其他字符应该怎么处理
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define Max 100
typedef struct Lnode
{
char data[Max];
int top;
}Lnode;
void creatlist(Lnode *&p)
{
p = (Lnode*)malloc(sizeof(Lnode));
p->data[p->top]=-1;
}
void push(Lnode *&p,char e)
{
p->top++;
p->data[p->top] = e;
}
void act(Lnode *&p)
{
p->top--;
}
int actlist(Lnode *&p,char e)
{
if(e=='('||e=='[')
{
push(p,e);
return 0;
}
if(e==')')
{
if(p->data[p->top]=='(')
{
act(p);
return 0;
}
else
{
// printf("NO");
return 1;
}
}
if(e==']')
{
if(p->data[p->top]=='[')
{
act(p);
return 0;
}
else
{
// printf("NO");
return 1;
}
}
}
int main()
{
char arr[Max]={0};
scanf("%s",&arr);
int a = strlen(arr);
printf("",a);
Lnode *p;
creatlist(p);
for(int i=0;i<a;i++)
{
if(actlist(p,arr[i]))
{
break;
}
}
// if(p->data[p->top]==-1)
// printf("YES");
if(p->data[p->top]!=-1)
printf("NO");
else
printf("YES");
return 0;
}
不知道你这个问题是否已经解决, 如果还没有解决的话:%a
浮点数、十六进制数字和p-记数法(C99)
%A
浮点数、十六进制数字和P-记法(C99)
%c
一个字符
%d
有符号十进制整数
%e
浮点数、e-记数法
%E
浮点数、E-记数法
%f
浮点数、十进制记数法(单精度)
%lf
双精度浮点数
%g
根据数值不同自动选择%f或%e,%e格式在指数小于-4或者大于等于精度时使用
%G
根据数值不同自动选择%f或%E,%E格式在指数小于-4或者大于等于精度时使用
%i
有符号十进制数(与%d相同)
%o
无符号八进制整数
%p
指针
%s
字符串
%u
无符号十进制整数
%x
使用十六进制数字0f的无符号十六进制整数(0f中是数字0,而不是字母o)
%X
使用十六进制数字0F的无符号十六进制整数
%%
打印一个百分号