📄 新建 文本文档 (4).txt
字号:
用栈的
#include "iostream.h"
#include "stdio.h"
#include "process.h"
#define N 100
typedef struct
{
char *base;
char *top;
}Stack;
void main()
{
Stack s;
char str[N];
int i = 0;
if(!(s.base = new char[N]))
{
cout<<"Malloc false....."<<endl;
exit(1);
}
s.top=s.base;
while(1)
{
str[i]=getchar();
if(str[i] == 10)
break;
else
{
*s.top++ = str[i];
i++;
}
}
i=0;
while(s.top != s.base)
{
cout<<*--s.top;
if(*s.top != str[i++])
{
cout<<endl<<"it is not a palindrome"<<endl;
break;
}
}
if(s.top == s.base)
cout<<endl<<"it is a palindrome"<<endl;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -