funguje
This commit is contained in:
parent
dd4548651f
commit
bf23b6fa99
@ -2,7 +2,7 @@
|
|||||||
#include<assert.h>
|
#include<assert.h>
|
||||||
#include<string.h>
|
#include<string.h>
|
||||||
#include<stdlib.h>
|
#include<stdlib.h>
|
||||||
|
#include<ctype.h>
|
||||||
#define STACK_SIZE 10
|
#define STACK_SIZE 10
|
||||||
|
|
||||||
struct stack
|
struct stack
|
||||||
@ -81,6 +81,18 @@ void print_stack(struct stack* mystack)
|
|||||||
printf(" \n");
|
printf(" \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int is_whitespace_only(const char* str)
|
||||||
|
{
|
||||||
|
while (*str)
|
||||||
|
{
|
||||||
|
if (!isspace((unsigned char)*str))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
@ -91,6 +103,11 @@ int main()
|
|||||||
{
|
{
|
||||||
int flag=switch_operators(input);
|
int flag=switch_operators(input);
|
||||||
input[strcspn(input,"\n")]=0;
|
input[strcspn(input,"\n")]=0;
|
||||||
|
if (strlen(input)==0 || is_whitespace_only(input))
|
||||||
|
{
|
||||||
|
printf("no input\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (flag==0 || flag==-1)
|
if (flag==0 || flag==-1)
|
||||||
{
|
{
|
||||||
if(flag==-1 && mystack.values[mystack.size-1]==0)
|
if(flag==-1 && mystack.values[mystack.size-1]==0)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user